Skip to main content
 首页 » 编程设计

Python 3 错误 : 'module' object has no attribute 'split'

2025年05月04日11Free-Thinker

<分区>

在 Python 2.7 解释器中,字符串拆分函数按预期工作:

>>> import string 
>>> a = "a b c" 
>>> string.split(a) 
['a', 'b', 'c'] 

但是,在 Python 3.4.1 解释器中,我得到一个错误:

>>> import string 
>>> a = "a b c" 
>>> string.split(a) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
AttributeError: 'module' object has no attribute 'split' 

知道我在这里遗漏了什么吗?

谢谢!