AttributeError:“列表"对象没有属性“拆分" [英] AttributeError: 'list' object has no attribute 'split'
本文介绍了AttributeError:“列表"对象没有属性“拆分"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Python 2.7.3.1
我不明白我的编码有什么问题!我收到此错误:AttributeError: 'list' object has no attribute 'split
I don't understand what the problem is with my coding! I get this error: AttributeError: 'list' object has no attribute 'split
这是我的代码:
myList = ['hello']
myList.split()
推荐答案
您可以按照以下步骤简单地执行list(myList[0])
:
You can simply do list(myList[0])
as below:
>>> myList = ['hello']
>>> myList=list(myList[0])
>>> myList
['h', 'e', 'l', 'l', 'o']
请参见文档此处
这篇关于AttributeError:“列表"对象没有属性“拆分"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文