首页 > 代码库 > python 输出彩色文字
python 输出彩色文字
直接上代码,写了一个选择双色球号码的小东西来显示字体颜色。
pip install clint
将以下代码复制,执行变可看到python在list与string转化,以及彩色文字的输出有多么方便了。
#!/usr/bin/python import random import string from clint.textui import colored red = [] blue = [] red_res=[] blue_res=[] for r in range(1,34): red.append(r) for b in range(1,17): blue.append(b) for i in range(6): a = random.choice(red) red_res.append(str(a)) red.remove(a) print colored.green("red ball are:")+colored.red(",".join(sorted(red_res))),colored.green("blue ball is:")+colored.blue(random.choice(blue))
本文出自 “技术为王” 博客,请务必保留此出处http://wangzhenyu.blog.51cto.com/2996939/1591106
python 输出彩色文字
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。