random_lines.py 263 Bytes
Newer Older
1
import random
2
import sys
3 4 5 6

number = int(sys.argv[1])
filename = sys.argv[2]

7
with open(filename) as f:
8 9
    lines = f.readlines()

10
random.seed("12345678")
11 12 13
linestoprint = random.sample(range(len(lines)), number)

for ln in linestoprint:
14
    print(lines[ln], end='')