- argparse - 命令行选项、参数和子命令解析器">argparse - 命令行选项、参数和子命令解析器
- colorama - 彩色输出">colorama - 彩色输出
- Clor - 彩色输出">Clor - 彩色输出
- python-cfonts - 高级彩色输出">python-cfonts - 高级彩色输出
- progressbar2 - 进度条">progressbar2 - 进度条
- fake-useragent - User Agent大全">fake-useragent - User Agent大全
- pyfiglet - 终端banner">pyfiglet - 终端banner
- PrettyTable - 表格输出">PrettyTable - 表格输出
- PyInquirer">PyInquirer
argparse - 命令行选项、参数和子命令解析器
import argparseparser = argparse.ArgumentParser()parser.add_argument("echo", help="echo the string you use here")args = parser.parse_args()print(args.echo)
然后我们得到:
$ python3 prog.py -husage: prog.py [-h] echopositional arguments:echo echo the string you use hereoptional arguments:-h, --help show this help message and exit
colorama - 彩色输出
from colorama import Fore, Back, Styleprint(Fore.RED + 'some red text')print(Back.GREEN + 'and with a green background')print(Style.DIM + 'and in dim text')print(Style.RESET_ALL)print('back to normal now')
Clor - 彩色输出
from colr import color# Examples:print(color('Hello world.', fore='red', style='bright'))# Examples (256 Colors):print(color('Hello world', fore=125, back=80))# Examples (True Color):print(color('Hello there.', fore=(255, 0, 0), back=(0, 0, 0)))# Examples (Hex):print(color('Hello there.', fore='ff0000', back='000'))
python-cfonts - 高级彩色输出
from cfonts import render, sayoutput = render('Hello world', colors=['red', 'yellow'], align='center')print(output)# 输出██╗ ██╗ ███████╗ ██╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██╗ ██████╗██║ ██║ ██╔════╝ ██║ ██║ ██╔═══██╗ ██║ ██║ ██╔═══██╗ ██╔══██╗ ██║ ██╔══██╗███████║ █████╗ ██║ ██║ ██║ ██║ ██║ █╗ ██║ ██║ ██║ ██████╔╝ ██║ ██║ ██║██╔══██║ ██╔══╝ ██║ ██║ ██║ ██║ ██║███╗██║ ██║ ██║ ██╔══██╗ ██║ ██║ ██║██║ ██║ ███████╗ ███████╗ ███████╗ ╚██████╔╝ ╚███╔███╔╝ ╚██████╔╝ ██║ ██║ ███████╗ ██████╔╝╚═╝ ╚═╝ ╚══════╝ ╚══════╝ ╚══════╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝
progressbar2 - 进度条
import timeimport progressbarfor i in progressbar.progressbar(range(100)):time.sleep(0.02)
fake-useragent - User Agent大全
from fake_useragent import UserAgentua = UserAgent()ua.ie# Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US);ua.msie# Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)'ua['Internet Explorer']# Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)ua.opera# Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11ua.chrome# Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2'ua.google# Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1290.1 Safari/537.13ua['google chrome']# Mozilla/5.0 (X11; CrOS i686 2268.111.0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11ua.firefox# Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1ua.ff# Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0.1ua.safari# Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25# and the best one, random via real world browser usage statisticua.random
pyfiglet - 终端banner
from pyfiglet import Figletf = Figlet(font='slant')print(f.renderText('text to render'))# 输出:__ __ __ __/ /____ _ __/ /_ / /_____ ________ ____ ____/ /__ _____/ __/ _ \| |/_/ __/ / __/ __ \ / ___/ _ \/ __ \/ __ / _ \/ ___// /_/ __/> </ /_ / /_/ /_/ / / / / __/ / / / /_/ / __/ /\__/\___/_/|_|\__/ \__/\____/ /_/ \___/_/ /_/\__,_/\___/_/
PrettyTable - 表格输出
from prettytable import PrettyTabletable = PrettyTable(["姓名", "性别", "年龄", "存款"])table.add_row(["赵一","男", 20, 100000])table.add_row(["钱二","男", 21, 500])table.add_row(["孙三", "男", 22, 400.7])table.add_row(["李四", "男", 23, 619.5])table.add_row(["周五", "男", 24, 1214.8])table.add_row(["吴六", "女", 25, 646.9])table.add_row(["郑七", "女", 26, 869.4])table.add_row(["王七加一", "男", 21, 869.4])print(table)'''结果+----------+------+------+--------+| 姓名 | 性别 | 年龄 | 存款 |+----------+------+------+--------+| 赵一 | 男 | 20 | 100000 || 钱二 | 男 | 21 | 500 || 孙三 | 男 | 22 | 400.7 || 李四 | 男 | 23 | 619.5 || 周五 | 男 | 24 | 1214.8 || 吴六 | 女 | 25 | 646.9 || 郑七 | 女 | 26 | 869.4 || 王七加一 | 男 | 21 | 869.4 |+----------+------+------+--------+'''
