Python-用户输入和字符串替换

name = input("name")

age = input("age")

job = input("job")

msg = '''
        info of %s
name = %s
age = %s
job = %s
''' % (name, name, age, job)

# print(msg)

msg2 = '''
        info of {_name}
name = {_name}
age = {_age}
job = {_job}
'''.format(_name=name, _age=age, _job=job)

# print(msg2)


msg3 = '''
        info of {0}
name = {0}
age = {1}
job = {2}
'''.format(name, age, job)
print(msg3)

你可能感兴趣的:(Python-用户输入和字符串替换)