這節(jié)練習 包括兩部分
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 #定義傳入?yún)?shù)
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()