格式化打印

'''
1、能够很规范的打印出想要的内容
2、双引号内没有办法放变量
'''

## 格式化输入
# %s    输入任意扥内容都不会报错因为全部当做str来处理
# %d    只能输入数字

#案例一
name = input("Name: ")
age = input("Age: ")
hosttown = input("HostTown: ")

info = '''
Name: %s
Age:%s
Hosttown: %s
'''%(name,age,hosttown)
print(info)

##案例二
name = input("name: ")
time = input("time:")
print("name:%s\ntime:%s" %(name,time))

猜你喜欢

转载自blog.51cto.com/swiki/2128667
今日推荐