Python help() 函数和 string.title 函数

标签 python

为什么不

import string;help(string.title) 

似乎可以,但是

help(string.strip)

工作正常吗?

我得到了错误

Traceback (most recent call last):
File "", line 1, in AttributeError: 'module' object has no attribute 'title'

最佳答案

titlestr 类型对象的方法,而不是 string 模块中的函数。这意味着您可以执行 "foo".title()str.title("foo") 但不能执行 string.title("foo").

关于Python help() 函数和 string.title 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2430166/

相关文章:

python - 在循环有序列表中找到最接近值的优雅方法

python - keras 中的自定义二进制交叉熵损失忽略没有非零值的列

python - 如何在 python 中获得超过 2 的 z alpha

python:如何加密文件?

python - pipenv 安装给出 "pew is not in your PATH"

python - 编写 Python 脚本以使用控制台命令执行

python - win32com Powerpoint 无法处理名称中的空格

python - 使用特定方法对嵌套的对象列表进行排序

python - Argparse 和 unittest.main()

python - Docker SDK for python中的auto_remove和remove有什么区别