博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python 命令行查看模块的具体使用方法
阅读量:4229 次
发布时间:2019-05-26

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

一般如果在 Windows 的话,而且你还安装了 Pycharm 集成开发环境的话,是没有这个困扰的(Ctrl + 鼠标点击 对象名,就直接可以查看具体函数的使用方法了)。以第三方模块 prettytable 为例:

import prettytable as pt# 按行添加数据tb = pt.PrettyTable()tb.field_names = ["id", "name", "phone", "age", "sex", "description"]tb.add_row([1, "zhangsan", "132****2889", 25.23, "M", "NoDesc"])tb.add_row([3, "lisi",     "152****7873", 18, "F", "None"])tb.add_row([5, "wangwu",   "136****2908", 25, "M", "Nothing"])tb.add_row([10,"zhaoliu",  "138****5322", 15, "M", "Nothing"])print(tb)# 按列添加数据create_time = ["2020-11-30 20:03:07", "2020-11-30 20:08:33", "2020-11-30 20:10:11", "2020-11-30 20:12:11"]tb.add_column("create_time", create_time)print(tb)------------------------------------------------------------# prettytable.py...class PrettyTable(object):    def __init__(self, field_names=None, **kwargs):        """Return a new PrettyTable instance        Arguments:        encoding - Unicode encoding scheme used to decode any encoded input        field_names - list or tuple of field names        fields - list or tuple of field names to include in displays        start - index of first data row to include in output        end - index of last data row to include in output PLUS ONE (list slice style)        header - print a header showing field names (True or False)...

还可以智能提示模块有哪些可以调用的函数以及可以的设置参数: 

如果是在命令行的怎么办?有没有可以查看的方法呢?(当然是有的啦!不要忘记 help 的作用哟)

[root@master ~]# python3Python 3.6.8 (default, Aug  7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linuxType "help", "copyright", "credits" or "license" for more information.>>> help('prettytable')Help on package prettytable:NAME    prettytablePACKAGE CONTENTS    prettytableCLASSES    builtins.object        prettytable.prettytable.PrettyTable    html.parser.HTMLParser(_markupbase.ParserBase)        prettytable.prettytable.TableHandler        class PrettyTable(builtins.object)     |  Methods defined here:     |       |  __getattr__(self, name)     |       |  __getitem__(self, index)     |       |  __init__(self, field_names=None, **kwargs)     |      Return a new PrettyTable instance     |      ...     |  add_row(self, row)     |      Add a row to the table     |           |      Arguments:     |           |      row - row of data, should be a list with as many elements as the table     |      has fields     |       |  add_rows(self, rows)     |      Add rows to the table     |           |      Arguments:     |           |      rows - rows of data, should be an iterable of lists, each list with as many     |      elements as the table has fields     |       |  clear(self)     |      Delete all rows and field names from the table, maintaining nothing but     |      styling options     |       |  clear_rows(self)     |      Delete all rows from the table but keep the current field names     |  ...

 

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

你可能感兴趣的文章
Fundamentals of OOP and Data Structures in Java
查看>>
C++ Network Programming, Vol. 1: Mastering Complexity with ACE and Patterns
查看>>
The Ethical Hack: A Framework for Business Value Penetration Testing
查看>>
Agile Development with ICONIX Process: People, Process, and Pragmatism
查看>>
Practical Guide to Software Quality Management
查看>>
Real Process Improvement Using the CMMI
查看>>
GDI+ Programming in C# and VB .NET
查看>>
Implementing and Integrating Product Data Management and Software Configuration Management
查看>>
Software Configuration Management
查看>>
Agile Project Management: How to Succeed in the Face of Changing Project Requirements
查看>>
MySQL Bible
查看>>
Palm OS Programming Bible
查看>>
XSLT Quickly
查看>>
Inside XSLT
查看>>
Python & XML
查看>>
Java Cryptography
查看>>
J2EE Best Practices: Java Design Patterns, Automation, and Performance
查看>>
Mastering AspectJ: Aspect-Oriented Programming in Java
查看>>
Mastering Jakarta Struts
查看>>
Java and XSLT
查看>>