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


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 ...... ")


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM