码迷,mamicode.com
首页 > 编程语言 > 详细

python路1---variable

时间:2017-05-31 10:10:41      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:密码   ctp   pad   支持   路由器   if...else   流程   put   ica   

#!/usr/bin/python3        #使用哪个python解释器运行该脚本

#python3默认编码为unicode,支持中文
name = 侯亮平
print (name)

#用户输入函数input()
import getpass
Username = input(Username:)
Passwd = input(Passwd:)
Passwd_get = getpass.getpass(Passwd:)        #密码隐式输入

print (type(Username),type(Passwd),type(Passwd_get))

#举例:录入一个产品信息,然后打印
ProductName = 六神花露水
ProductBrand = 六神
ProductPlace = 中国上海
Productfunc = 驱蚊止痒
Productprice = 9.8
print (
    ‘‘‘
    --------------产品信息--------------
    产品名:%s
    品牌  :%s
    产地  : %s
    功效  : %s
    价格      : %f    

    ‘‘‘    % (ProductName,ProductBrand,ProductPlace,Productfunc,Productprice)

    )

#流程语句 :if...else
#举例:模拟cisco路由器的登录认证,三次尝试失败需等待10s,
import getpass
import time
import os
Count = 0
while True:
    UserName = input(Username:)
    PassWd = getpass.getpass(Passwd:)
    if  UserName ==cisco and PassWd == cisco:
        print (Congrituations :authentication successed!!)
        break
    else:
        print (Authencation failed:username not exist or passwd not right )
        Count +=1
        if Count == 3 :
            print (Try too many times,Please wait ten seconds)
            time.sleep(10)
            os.system(clear)
            Count = 0

python路1---variable

标签:密码   ctp   pad   支持   路由器   if...else   流程   put   ica   

原文地址:http://www.cnblogs.com/tobet/p/6921912.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!