天天看点

Python字符串格式化

这篇完全手打加深对于格式化输出的理解

name = input("name:")

age = int(input("age:"))

occupation = input("occupation:")

salary = int(input("salary:"))

msg = ''' %s Profile

name: %s

age: %d

occupation: %s

salary: %d

''' % (name, name, age, occupation, salary)

print(msg)