Skip to main content
 首页 » 编程设计

python之我一直在学习python 3.5,并试图获取一个字符串来转载用户输入的变量

2024年10月17日25txw1958

print ("how old are you??"), 
age = input() 
print("How tall are you"), 
height = input() 
print("How much do you weigh"), 
weight = input() 
 
print("So, you're '%r' old, '%r' tall and weigh '%r' ") % ('age, height weight') 

TypeError: %: 'NoneType' 和 'str 不支持的操作数类型

请您参考如下方法:

不要将变量放在引号中。而不是

print("So, you're '%r' old, '%r' tall and weigh '%r' ") % ('age, height weight') 

放

print("So, you're '%r' old, '%r' tall and weigh '%r' " % (age, height weight))