标签:odi color from csdn 文件名 input south 赋值 water
代码如下:
1 #coding:utf-8 2 from sys import argv 3 4 script, filename = argv 5 6 txt = open(filename) #将打开的文件内容赋值给变量txt 7 8 print "Here‘s your file %r:" % filename 9 print txt.read() #读取txt的内容 10 11 print "Type the filename again:" 12 file_again = raw_input("> ") #玩家输入新文件的文件名,并且将文件名赋值给file_again 13 14 txt_again = open(file_again) #将新文件打开,并将新文件内容赋值给txt_again 15 16 print txt_again.read() #读取txt_again的内容 17 18 txt.close() 19 txt_again.close()
运行结果:
标签:odi color from csdn 文件名 input south 赋值 water
原文地址:http://www.cnblogs.com/p36606jp/p/7648174.html