python光速入门教程

阅读: 评论:0

python光速入门教程

python光速入门教程

使用help自学函数用法

print()、eval()、input()、help(),这些是最基本的python函数。当我们遇到不会使用的函数时,先使用help()查看函数的文档,里面有丰富的说明,也配备了详细的demo进行演示,十分方便。这些文档资源是学习的利器。 顺便提一句,软件就是由计算机程序以及文档组成的,文档是十分重要的,一个好的文档对于学习的帮助极大。

下面举例说明如何使用help函数,在pycharm中,输入以下代码。

help(print)  # 不能够使用help(print())

就能得到以下结果

print(...)print(value, ..., sep=' ', end='n', file=sys.stdout, flush=False)Prints the values to a stream, or to sys.stdout by default.Optional keyword arguments:file:  a file-like object (stream); defaults to the current sys.stdout.sep:   string inserted between values, default d:   string appended after the last value, default a newline.flush: whether to forcibly flush the stream.

这里需要注意,python中,函数加上括号表示对函数进行了调用,因此在使用help时,不能够在print函数后面加上括号。

在pycharm中查看函数用法

此外,在pycharm中,我们也能够通过“按住ctrl键并鼠标左击函数名”的方式进入函数内部查看函数是如何实现的。当然,有一些python的函数是通过调用C或C++的程序来实现的,此时进入到函数中是看不到代码的,只有接口说明,这时只需百度该函数了解其用法即可。

例如,在pycharm中ctrl+左击 print函数,可以看到

def print(self, *args, sep=' ', end='n', file=None): # known special case of print"""print(value, ..., sep=' ', end='n', file=sys.stdout, flush=False)Prints the values to a stream, or to sys.stdout by default.Optional keyword arguments:file:  a file-like object (stream); defaults to the current sys.stdout.sep:   string inserted between values, default d:   string appended after the last value, default a newline.flush: whether to forcibly flush the stream."""pass

以上就是自学函数使用方法的操作步骤。

本文发布于:2024-02-04 12:07:03,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170706836755420.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:光速   入门教程   python
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23