我是一个新手,Python和从Python Tutorial的Python:打印文件的内容到终端
阅读了有关文件,所以,我做了一个小程序,练习文件处理:
from sys import *
script , file_name = argv
print "Your file is : %s" %file_name
print "Opening the file..."
temp = open(file_name, 'r+')
print "Truncating the file "
temp.truncate()
print "Enter three lines."
line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input("line 3: ")
print "Writing these to the file."
temp.write(line1)
temp.write("\n")
temp.write(line2)
temp.write("\n")
temp.write(line3)
temp.write("\n")
#for line in temp:
#print line
#temp.read()
print "Closing it."
temp.close()
我的问题:在共
不知怎的,我无法打印文件,使用任一注释(#)的终端的内容陈述德以上。有人可以帮我吗 ?
谢谢@Aaron,这非常有帮助:) – pranav 2015-03-25 03:29:23