Python学习二:格式化输出

Name = input('Name: ')
Age = input('Age: ')
Position = input('Position: ')
Income = input('Income: ')

if Income.isdigit(): #判断Income是否为str型的数字
Income = int(Income)
else:
quit("Income not's digit") #Income是数字,程序终止

msg = '''
---------now is %s---------
Name is : %s
Age is : %s
Position is : %s
Income is: %s
-------it's over here------
''' % (Name,Name,Age,Position,Income)

print(msg)
'''
%s 字符串
'''

猜你喜欢

转载自www.cnblogs.com/CatdeXin/p/10156120.html