1. 程式人生 > >python基礎----variale if..else input print

python基礎----variale if..else input print

span padding authent time ces enca func style 默認

#!/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基礎----variale if..else input print