[英]ERROR: AttributeError: '_io.TextIOWrapper' object has no attribute 'split'
This is my code: 这是我的代码:
line = open('save_file.txt')
s = {}
(s['nome'], s['race'], s['classes'], s['FOR'], s['INT'], s['DES']) = line.split(";")
print("Nome: " + s['nome'])
print("Raça: " + s['race'])
I'm trying to print the things that are in the save_file
, but when I start the program the error of the title appears. 我正在尝试打印
save_file
中的save_file
,但是当我启动程序时,出现标题错误。 Someone can help? 有人可以帮忙吗? Thanks for the attention.
感谢您的关注。
open
returns file object, not line. open
返回文件对象,而不是行。 You need something like 你需要类似的东西
f = open('save_file.txt')
for line in f:
#do stuff
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.