Python----常用的__doc__、__name__、__file__的使用
2020-12-13 01:35
阅读:530
标签:doc img return bin ima name inf 路径 int
各自的作用:
__doc__:获取到注释内容
__name__:获取到函数的名称
__file__:获取到当前的文件路径
示例代码:
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author:lucky,time:2019-06-10 def my_python(): """This is my python""" return ("From my python!") print my_python() print(my_python.__doc__) print (my_python.__name__) print __file__
结果展示:
Python----常用的__doc__、__name__、__file__的使用
标签:doc img return bin ima name inf 路径 int
原文地址:https://www.cnblogs.com/syw20170419/p/11002882.html
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:Python----常用的__doc__、__name__、__file__的使用
文章链接:http://soscw.com/index.php/essay/23886.html
文章标题:Python----常用的__doc__、__name__、__file__的使用
文章链接:http://soscw.com/index.php/essay/23886.html
评论
亲,登录后才可以留言!