这就是我到目前为止所拥有的,我尝试的所有内容都表明文件未打开?有什么基本的方法可以解决这个问题吗?
liNames = []
while 1 == 1:
liNames += [raw_input("Tell me a name. Type DONE(all caps) if done entering:")]
if "DONE" in liNames:
break
del liNames[-1]
print liNames
name_file = open("names.txt","w")
line = name_file.writelines(liNames)
for line in name_file:
print line
name_file.close()