Name = input("name:")
Age = int(input("Age:"))#integer,强制变成整数
print(type(Age) , type(str(Age))) #又改回字符串格式
Job = input("Job:")
Salary = input("Salary:")
info = ‘‘‘
---------- info of %s ------- Name:%s Age:%d Job:%s Salary:%s
‘‘‘ % (Name,Name,Age,Job,Salary)
print(info)
# %d帮助检测数据类型,强制整数而不是字符串,%f 就是小数
#raw_input 2.x input 3.x
#input 2.x是变量,不认为是字符串,需要定义,尽量不用
示例5:
Name = input("name:")
Age = int(input("Age:"))#integer,强制变成整数 print(type(Age) , type(str(Age))) #又改回字符串格式
Job = input("Job:")
Salary = input("Salary:")
info2 = ‘‘‘
---------- info of {Name} ------- Name:{Name} Age:{Age} Job:{Job} Salary:{Salary}
‘‘‘ .format(Name = Name,
Age = Age,
Job = Job,
Salary =Salary)
print(info2)