标签:for循环 结束 内容 格式化 ali break 输出 char pycha
#_*_coding:utf-8_*_
#作者:王佃元
#日期:2019/12/6
#格式化输出
name = input("Name")
age = input("Age")
job = input("Job")
salary = input("Salary")
msg = ‘‘‘
------------ info of %s------------
Name : %s
Age : %s
Job : %s
Salary :%s
-------------- end ----------------
‘‘‘%(name,name,age,job,salary)
print(msg)
‘‘‘
如何让上述内容按照既定的格式输出?
------------ info of drey------------
Name : dery
Age : 35
Job : it
Salary : 3000
-------------- end ----------------
name,name,age,job,salary
python中使用%s
‘‘‘
#_*_coding:utf-8_*_
#作者:王佃元
#日期:2019/12/6
#用户登录程序
#for循环的用法:for i in range(a,b,c)
#a,b,b分别为:a表示起始值、b表示结束值、c表示步长
# _user_ = "dery"
# _password = "abc"
# passed_check = False
# for i in range(3):
# username = input("username:")
# password = input("password:")
# if username == _user_ and password == _password :
# print("welcome is login .....")
# passed_check = True
# break
# else:
# print("Invalid username or password")
# if not passed_check:
# print("要不要脸,臭流氓!")
_user_ = "dery"
_password = "abc"
for i in range(3):
username = input("username:")
password = input("password:")
if username == _user_ and password == _password :
print("welcome is login .....")
break
else:
print("Invalid username or password")
else:
print("要不要脸,臭流氓!")
# for i in range(101):
# if i%2 == 0
# print(i)
#
# for i in range(100):
# if i > 70 or i < 50:
# print(i)
标签:for循环 结束 内容 格式化 ali break 输出 char pycha
原文地址:https://www.cnblogs.com/python-beginner/p/12000323.html