需要的库有random,linecache
代码如下:

import random,linecache
def random_line(filename):
 a = random.randrange(1,10)
 theline = linecache.getline(filename,a) 
 return theline