博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python有用的命令
阅读量:4042 次
发布时间:2019-05-24

本文共 1315 字,大约阅读时间需要 4 分钟。

Python有用的命令

1、dir([object]):列出某个类型所有可用的方法

参数object,可以是对象、变量、类型。如:

>>> str1 = 'a'>>> dir(str1)#查看一下list中存在哪些内置函数>>> dir(list)['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

2、help():查看函数用法详解

在使用python编写代码时,会经常使用python自带的函数或模块,对一些不常用的函数或模块不是很清楚时,就可以使用该命令去查看详细的帮助信息。
help()函数中的参数是函数的名字。如:查看字符串分割函数split

>>> 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.

转载地址:http://ydmdi.baihongyu.com/

你可能感兴趣的文章
Vue-子组件改变父级组件的信息
查看>>
Python自动化之pytest常用插件
查看>>
Python自动化之pytest框架使用详解
查看>>
【正则表达式】以个人的理解帮助大家认识正则表达式
查看>>
性能调优之iostat命令详解
查看>>
性能调优之iftop命令详解
查看>>
非关系型数据库(nosql)介绍
查看>>
移动端自动化测试-Windows-Android-Appium环境搭建
查看>>
Xpath使用方法
查看>>
移动端自动化测试-Mac-IOS-Appium环境搭建
查看>>
Selenium之前世今生
查看>>
Selenium-WebDriverApi接口详解
查看>>
Selenium-ActionChains Api接口详解
查看>>
Selenium-Switch与SelectApi接口详解
查看>>
Selenium-Css Selector使用方法
查看>>
Linux常用统计命令之wc
查看>>
测试必会之 Linux 三剑客之 sed
查看>>
Socket请求XML客户端程序
查看>>
Java中数字转大写货币(支持到千亿)
查看>>
Java.nio
查看>>