python条件语句和变量赋值-创新互联
python的条件语句
字符串内变量赋值的方法
创新互联专注于获嘉企业网站建设,响应式网站,购物商城网站建设。获嘉网站建设公司,为获嘉等地区提供建站服务。全流程按需定制网站,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务name = input("name:")
age = int(input("age:"))
job = input("job:")
salary = input("salary:")
info = '''
---------- info of %s ----------
Name:%s
Age:%d
Job:%s
Salary:%s
''' % (name,name,age,job,salary)
info2 = '''
---------- info of {_name} ----------
Name:{_name}
Age:{_age}
Job:{_job}
Salary:{_salary}
''' .format(_name=name,_age=age,_job=job,_salary=salary)
print(info2)
if
import getpass
_username = "asdf"
_password = "123"
username = input("username:")
#password = getpass.getpass("password:")
password = input("password:")
if _username == username and _password == password:
print("welcome user {name} login...".format(name=username))
else:
print("Invalid username or password!")
while
age_of_oldboy = 56
count = 0
while count < 3:
guess_age = int(input("guess age:"))
if guess_age == age_of_oldboy:
print("you got it!")
break
elif guess_age > age_of_oldboy:
print("thing smaller")
else:
print("think bigger")
count +=1
else:
print("you try too many")
for
age_of_oldboy = 56
count = 0
for i in range(3):
guess_age = int(input("guess age:"))
if guess_age == age_of_oldboy:
print("you got it!")
break
elif guess_age > age_of_oldboy:
print("thing smaller")
else:
print("think bigger")
else:
print("you try too many")
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享题目:python条件语句和变量赋值-创新互联
当前网址:http://myzitong.com/article/jecdc.html