首页 > 编程语言 > 详细

python中3个帮助函数help、dir、type的使用

时间:2015-12-09 19:16:51      阅读:198      评论:0      收藏:0      [点我收藏+]

1、help函数:查看模块、函数、变量的详细说明:

查看模块 help("modules")

查看包  help("json")

查看类 help(json.JSONDecoder)

查看函数 help(json.dump)

 

2、dir函数:查看变量可用的函数或方法

>>> import time
>>> dir(time)
[‘__doc__‘, ‘__name__‘, ‘__package__‘, ‘accept2dyear‘, ‘altzone‘, ‘asctime‘, ‘clock‘, ‘ctime‘, ‘daylight‘, ‘gmtime‘, ‘localtime‘, ‘mktime‘, ‘sleep‘, ‘strftime‘, ‘strptime‘, ‘struct_time‘, ‘time‘, ‘timezone‘, ‘tzname‘]

 

3、type函数:查看变量的类型

<type ‘module‘>
>>> type (json.__name__)
<type ‘str‘>
>>> type (json.decoder)
<type ‘module‘>

>>> type(123)
<type ‘int‘>
>>> type("aaa")
<type ‘str‘>

python中3个帮助函数help、dir、type的使用

原文:http://www.cnblogs.com/linuxtech/p/5033650.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!