string.split 错误?Python [英] string.split error? python
本文介绍了string.split 错误?Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
a = string.split("Test Test2 Test3"," ")
这会返回一个错误:
Message File Name Line Position
Traceback
<module> C:\pyWiz.py 43
AttributeError: 'module' object has no attribute 'split'
是的,我导入了字符串模块.为什么会发生这种情况?
Yes, I imported the string module. Why is this happening?
推荐答案
使用:
a = 'Test Test2 Test3'.split(' ')
(即 str
类型的 split
方法).string.split
在 2.x 中被弃用,在 3.x 中消失.
(i.e. split
method of str
type). string.split
is deprecated in 2.x and gone in 3.x.
这篇关于string.split 错误?Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文