这节练习 包括两部分
txt 文件部分 (文件名 : 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.
py部分
from sys import argv
script,filename = argv #定义传入参数
txt = open(filename) #打开txt文件
print "Here's your file %r:" %filename #打印文字
print txt.read() #显示文件内容
print "Type the filename again:"
file_again = raw_input("> ") #再次输入文件名字
txt_again = open(file_again)
print txt_again.read()
网友评论