我试图通过阅读zedshaw的《艰难地学习Python》来学习Python,但我却陷入了一个看似微不足道的问题上。我找不到有关.read()方法的任何信息。这是他在书中所说的:
Run pydoc file and scroll down until you see the .read() command (method/function). See all the other ones you can use? Skip the ones that have __ (two underscores) in front because those are junk. Try some of the other commands.
如果我调用python -m pydoc
,我只得到一个关于pydoc.py
、pydoc.py -k
、pydoc.py -p
、pydoc.py -g
、和{
当我试图拨打python -m pydoc read
时,我收到了以下消息:
no Python documentation found for 'read'
默认情况下,.read
方法是嵌入在Python中的,还是必须先导入它?我应该注意我在Windows7上使用的是Powershell。有什么问题吗?在
注意Exercise 15中的格式:
这不是偶然的;您需要的命令就在这里:
read
是一个文件对象的方法。使用:获取文件对象的文档。请注意,这正是本书告诉您要做的,但它似乎是您离开了
file
参数。在或者,只要求方法:
^{pr2}$然而,官方文件要丰富和有用得多。例如,请参阅有关File Objects的文档。在
相关问题 更多 >
编程相关推荐