本文共 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/