Python开发 基础篇

2019-02-01

产生验证码:

用户输入的值和显示的值相同时显示Correct,否则继续生成随机验证码等待用户输入

 1 def check_code():
 2     import random
 3     checkcode=''
 4     for i in range(4):
 5         current=random.randrange(0,4)
 6         if current != i:
 7             temp=chr(random.randint(65,90))
 8         else:
 9             temp= random.randint(0,9)
10         checkcode +=str(temp)
11     print(checkcode)
12     p=input('>>>')
13     while checkcode==p:
14         print('Correct')
15         break
16     else:
17         check_code()
18 check_code()

敏感词过滤:

提示用户输入内容,如果用户输入的内容中包含“苍老师”或者“东京热”,则将替换为“***”

1 i=input()
2 i=i.replace('苍老师',"***")
3 i=i.replace('东京热',"***")
4 print(i)

利用输入的用户名、密码、邮箱制作表格:

循环提示用户输入:用户名、密码、邮箱(要求用户输入的长度不超过20个字符,如果超过则只有前20个字符有效)

如果用户输入q或Q表示不再继续输入,将用户输入的内容以表格形式打印

#未完成
s=''
while True:
    v1 = input('用户名:')
    v2 = input('密码:')
    v3 = input('邮箱:')
    template="{0}\t{1}\t{2}\n"
    v=template.format(v1,v2,v3)
    s=s+v
    print(s.expandtabs(20))

 

 

 

 

转载于:https://www.cnblogs.com/JasonPeng1/p/10346108.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值