Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get random line from file python

import random
lines = open('file.txt').read().splitlines() # creates a list with one line per item
randomLine =random.choice(lines) # pick up a random item in this list
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #random #line #file #python
ADD COMMENT
Topic
Name
2+8 =