<分区> 分区>
我使用这段代码创建了一个文件:
file = open("full_names.txt", "wb")
file.write("Bob Smith\nMichael Jackson\nTony Tiger\nWinston Churchill\nHenry Kissinger\nHamid Karzai\nJohn Major\nJohnny Quest")
file.close()
然后我运行脚本将文件打印到屏幕上:
with open("full_names.txt", "rb") as f:
for line in f:
first, last = line.strip().split(" ")
print "Last Name: %r First Name: %r" % (last, first)
但输出显示名称周围有引号,如下所示:
Last Name: 'Smith' First Name: 'Bob'
有谁知道为什么或如何摆脱它们?
