Python: pass arguments to a script
问题 I have a working code to print random lines from a csv column. #!/usr/bin/python import csv import random **col**=2 with open('<filename>','r') as f: reader=csv.reader(f) data=[row[col] for row in reader] from random import shuffle shuffle(data) print '\n'.join(data[:**100**]) f.close(); I want to paramaterize this script. by passing , position (col) & sample (e.g. 100 values) I am unable to find a decent tutorial which would explain this. any thoughts ? 回答1: You can use the sys module like