python加颜色_可以为python输出添加颜色吗?

因此,我为我、我的朋友和我的家人做了一个小型密码强度测试仪,如下所示:import re

strength = ['You didnt type anything','Terrible','weak sause','avarage','Good!','Very Strong', 'THE FORCE IS STRONG WITH THIS ONE']

score = 1

password=(raw_input("please type in the password you would like rated:"))

if len(password) < 1:

print strength[0]

if len(password) >=1 and len(password)<=4:

print strength[1]

else:

print ""

if len(password) >=7:

score+=1

print "password was made stronger by not being short"

else:

print "Your password is really short, concider making it longer"

if len (password) >=10:

score+=1

print "password was made stronger by long"

else:

print "An even longer password would make it stronger"

if re.search('[a-z]',password) and re.search('[A-Z]', password):

score+=1

print "password was made stronger by having upper & lower case letters"

else:

print "Indlucing both upper and lower case letters will make your password stronger"

if re.search('[0-9]+', password):

score+=1

print "Password was made stronger by using numbers"

else:

print "Using numbers will make your password stronger"

if re.search('[.,!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]',password):

score+=1

print "Password was made stronger by using punctuation marks and characters"

else:

print "Using punctuation marks and characters will make the password stronger"

print "\n final password rating is:"

print strength[score]

我想做的是:

第一-给用户关于密码内容的评论添加颜色,好的评论如:"password was made stronger by using numbers"将有一个绿色的输出,而建设性的反馈,如"using numbers will make your password stronger"将有一个红色的输出,使用户更容易发现他的密码的利弊

第二,我想知道,如果它的工作原理相同,我能给我上面的“力量”列表中的某些项目上色吗?让前两对红,中间一对黄,最后一对绿?在

泰!在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值