为什么不
import string;help(string.title)
似乎可以,但是
help(string.strip)
工作正常吗?
我得到了错误
Traceback (most recent call last):
File "", line 1, in AttributeError: 'module' object has no attribute 'title'
最佳答案
title
是 str
类型对象的方法,而不是 string
模块中的函数。这意味着您可以执行 "foo".title()
或 str.title("foo")
但不能执行 string.title("foo")
.
关于Python help() 函数和 string.title 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2430166/