资讯专栏INFORMATION COLUMN

python帮助说明

yankeys / 2912人阅读

摘要:当遇到陌生的模块的时候,如何查询,一直是很模糊的概念。查看变量类型应该是,只能查看类型或者函数的帮助查看对象所有的方法关于两条下划线的代表什么意思,参见这篇下划线使用注意疑问只有方法,没有属性么疑问为什么有些加下划线了,有些并没有加上。

  

用的了python写脚本,也只是理解后ctrl+s,代码复用。当遇到陌生的模块的时候,如何查询,一直是很模糊的概念。今天记录点,也当时工具笔记了。

type(var_1)查看var_1变量类型

help(var_1) ERROR,应该是help(type(var_1)),只能查看类型或者函数的帮助

>>> a="111"
>>> a
"111"
>>> help(a)
no Python documentation found for "111"

>>> help(type(a))
Help on class str in module __builtin__:

class str(basestring)
 |  str(object="") -> string
 |

-----------------------------


>>> help(split)
Traceback (most recent call last):
  File "", line 1, in 
NameError: name "split" is not defined
>>> help(str.split)
Help on method_descriptor:

split(...)
    S.split([sep [,maxsplit]]) -> list of strings

    Return a list of the words in the string S, using sep as the
    delimiter string.  If maxsplit is given, at most maxsplit
    splits are done. If sep is not specified or is None, any
    whitespace string is a separator and empty strings are removed
    from the result.

dir(var_1) 查看var_1对象所有的方法
关于两条下划线的代表什么意思,参见这篇python下划线使用注意

  

疑问1:只有方法,没有属性么
疑问2:为什么有些加下划线了,有些并没有加上。

>>> dir(a)
["__add__", "__class__", "__contains__", "__delattr__", "__doc__", "__eq__", "__
format__", "__ge__", "__getattribute__", "__getitem__", "__getnewargs__", "__get
slice__", "__gt__", "__hash__", "__init__", "__le__", "__len__", "__lt__", "__mo
d__", "__mul__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__",
 "__rmod__", "__rmul__", "__setattr__", "__sizeof__", "__str__", "__subclasshook
__", "_formatter_field_name_split", "_formatter_parser", "capitalize", "center",
 "count", "decode", "encode", "endswith", "expandtabs", "find", "format", "index
", "isalnum", "isalpha", "isdigit", "islower", "isspace", "istitle", "isupper",
"join", "ljust", "lower", "lstrip", "partition", "replace", "rfind", "rindex", "
rjust", "rpartition", "rsplit", "rstrip", "split", "splitlines", "startswith", "
strip", "swapcase", "title", "translate", "upper", "zfill"]
>>>

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/37589.html

相关文章

  • Python中的测试工具

    摘要:模块会搜索那些看起来像是交互式会话中的代码片段,然后尝试执行并验证结果。方法检车指定的条件这里是相等,以判断指定的测试是成功了还是失败了。   当我们在写程序的时候,我们需要通过测试来验证程序是否出错或者存在问题,但是,编写大量的测试来确保程序的每个细节都没问题会显得很繁琐。在Python中,我们可以借助一些标准模块来帮助我们自动完成测试过程,比如: unittest: 一个通用的测...

    zhjx922 评论0 收藏0
  • Python技能树》Python简介

    摘要:火爆是当今非常热门的语言之一,根据年月编程语言排行,荣获年度编程语言称号,并且其流行度依然处在上升势头。学习完技能树之后,你将进入编程的大门,明白编程的作用,建立编程的兴趣方法和习惯。 ? 作者主页:不吃西红柿  ? 简介:CSDN博客专家?、HDZ核心组成员? 、Python领域优质创作者...

    BlackMass 评论0 收藏0
  • 使用 Python 编写一个 Memcached 的 CLI

    摘要:原文地址近期在项目中使用到了相比较为齐全的工具这个非关系型数据库客户端只能通过与服务器端进行交互于是有了为这个数据编写个简便的客户端工具的想法。如果用户没有传入对应的参数则使用默认的参数进行绑定。 原文地址: http://52sox.com/use-python-write-a-memcached-cli/ 近期在项目中使用到了Memcached,相比redis较为齐全的工具,这个非...

    RdouTyping 评论0 收藏0
  • 使用 Python 编写一个 Memcached 的 CLI

    摘要:原文地址近期在项目中使用到了相比较为齐全的工具这个非关系型数据库客户端只能通过与服务器端进行交互于是有了为这个数据编写个简便的客户端工具的想法。如果用户没有传入对应的参数则使用默认的参数进行绑定。 原文地址: http://52sox.com/use-python-write-a-memcached-cli/ 近期在项目中使用到了Memcached,相比redis较为齐全的工具,这个非...

    aisuhua 评论0 收藏0
  • python-trezor 安装说明

    摘要:第三步可选官方说明执行以上命令语句这里会出现错误,提示时命令不可用执行安装的支持再执行便可以成功了。 repo地址: https://github.com/trezor/pyt...git clone https://github.com/trezor/pyt...说明:Client side implementation for TREZOR-compatible Bitcoin h...

    cpupro 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<