Python 2.7: no documentation found when typing help('print')

本文解决在安装了Python2.7的Ubuntu12.04上,使用help()函数获取文档时遇到的问题。通过帮助文档发现,在Python2.7中打印相关函数作为特殊关键字处理,因此直接调用help('print')会失败。解决方案是在调用help()时指定使用内置打印函数,即help('__builtin__.print')。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文转自http://askubuntu.com/questions/230994/python-2-7-no-documentation-found-when-typing-helpprint

I have just installed Python 2.7 and Python 3.2 on my Ubuntu 12.04 (32 bit).

sudo apt-get install python python-doc python3 python3-doc

I opened a Python 3 shell (is it called like that) typing python3 from a terminal.If I issue the commandhelp('print') everything works fine and I can read the documentation.

However if I open a Python 2.7 shell (python from a terminal) when I typehelp('print') I get the following message:

no documentation found for 'print'

How can I get to use the documentation in Python 2.7 as well?




This looks like a bug of Python 2 as something like help("dir") works properly. It probably does not work becauseprint is a special keyword, unlike Python 3. Stick to Python 3 or run the following command instead ofhelp("print"):

help("__builtin__.print")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值