ex15.py
from sys import argv
script,file_name = argv
with open(file_name, mode='r') as f:
txt = f.read()
print "Here's your file %r:"%file_name
print txt
運行結(jié)果:
J:\python\program\ex>python ex15.py ex15_sample.txt
Here's your file 'ex15_sample.txt':
This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.