简体   繁体   English

错误:AttributeError:'_io.TextIOWrapper'对象没有属性'split'

[英]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.

相关问题 AttributeError:'_io.TextIOWrapper'对象没有属性'split'错误 - AttributeError: '_io.TextIOWrapper' object has no attribute 'split' error Python:AttributeError:'_ io.TextIOWrapper'对象没有属性'split' - Python: AttributeError: '_io.TextIOWrapper' object has no attribute 'split' Python问题:AttributeError:'_ io.TextIOWrapper'对象没有属性'split' - Python Issue: AttributeError: '_io.TextIOWrapper' object has no attribute 'split' Python-错误-AttributeError:“ _ io.TextIOWrapper”对象没有属性“插入” - Python - Error - AttributeError: '_io.TextIOWrapper' object has no attribute 'insert' Python “AttributeError: '_io.TextIOWrapper' object has no attribute 'append'” 错误 - Python “AttributeError: '_io.TextIOWrapper' object has no attribute 'append'” error AttributeError: '_io.TextIOWrapper' 对象没有 txt 文件的属性 'lower' - AttributeError: '_io.TextIOWrapper' object has no attribute 'lower' for txt file AttributeError: '_io.TextIOWrapper' 对象没有属性 'next' python - AttributeError: '_io.TextIOWrapper' object has no attribute 'next' python AttributeError:'_io.TextIOWrapper'对象没有属性'next'? - AttributeError: '_io.TextIOWrapper' object has no attribute 'next'? Python说:AttributeError:'_io.TextIOWrapper'对象没有属性' - Python says: AttributeError: '_io.TextIOWrapper' object has no attribute ' AttributeError:'_io.TextIOWrapper'对象没有属性'decode' - AttributeError: '_io.TextIOWrapper' object has no attribute 'decode'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM