python - 我一直在学习 python 3.5,并试图获取一个字符串来重新打印用户输入变量?

标签 python string user-input

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')

类型错误:% 不支持的操作数类型:“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))

关于python - 我一直在学习 python 3.5,并试图获取一个字符串来重新打印用户输入变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39460040/

相关文章:

python - 在 Windows 后台根据键盘记录器输入运行 Python Clicker

python 元组打印问题

python - 在python中添加矩阵中的元素

php - 检查字符串是否包含 float

java - 如何在 while 循环中安全地扫描整数?

java - 尝试将用户输入与文本文件进行比较,然后在java上读取该点的数字值

python - 同时运行多个循环

python - 无法加载资源: the server responded with a status of 403 (Forbidden) django framework

python - 等效于 R 在 Python 中用于数字向量的粘贴命令

php - 哪个性能更好 : double quoted strings with variables or single quoted strings with concatenations?