数字与字符串互转及拼接方法

death_age = 80


name = input("your name:")
age = input("your age:") #input
#接收的所有数据都是字符串,即便你输入的是数字,但依然会被当成字符串来处理

print( type(age))
#int integer =整数 把字符串转成int,用int(被转成的数据)
#srt string = 字符串 把数据转成字符串用str(被转成的数据)
print("Your name:",name)
# str 强制转成字符串
#print("Your can still live fur ",str(death_age - int(age)),"years ...... ") =三个独立的字符串
#print("Your can still live fur " + str(death_age - int(age)) +"years ...... ") =拼接成一个字符串
print("Your can still live fur ",death_age - int(age),"years ...... ")

posted @ 2017-10-13 13:46  创联文化  阅读(2113)  评论(0编辑  收藏  举报