我编写了以下python代码来播放文件
from sys import argv
script , fn = argv
print "We shall play with files\n"
print "You chose the file '%s'\n" %fn
print"We shall now play with the file\n"
x = open(fn,'w+')
print "Let's write something into the file\n"
y = raw_input("What do you want to be written into the file?\n")
x.write(y)
print"Here's what you wrote into the file\n"
z = x.read()
print z
现在的问题是,当我运行文件并输入y的字符串值时,python没有显示任何错误,但在输出中,没有任何内容打印在这里,你写入文件的内容除了大量的空格和新线。当我打开文本文件时,字符串存在但是也存在许多[NULL]字符。知道为什么会这样吗?