python - 错误 "not all arguments converted during string formatting"这里出了什么问题?

标签 python python-3.x

name = input ("What is your name?")
quest = input("What is your quest?")
color = input ("what is your favorite color")

print ("Ah, so your name is {}, your quest is{}, and your favorite color is{}.")str.format(name, quest, color)

最佳答案

.format() 是字符串上的方法。您需要在模板字符串上调用它:

print("Ah, so your name is {}, your quest is{}, and your favorite color is{}.".format(name, quest, color))

请注意 .format() 如何直接跟在 “Ah, so ... is{}.” 字符串定义之后,以及结果<该方法的/em> 被传递给 print(...) 函数进行打印。

关于python - 错误 "not all arguments converted during string formatting"这里出了什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40162755/

相关文章:

python - 如何从entrycompletion获取entry

python - Mailgun 批量发送中的 BCC 不包括替换

python - tkinter.messagebox.showinfo 并不总是有效

python-3.x - 使用 Dask 进行并行学习

python - 匹配两个具有最大重复次数的唯一字符。如何使用正则表达式提取它?

python - 在两种不同颜色之间更改像素颜色

python - 无法使用 pymongo 2.2 连接到 MongoDB 2.0.5 数据库

python-3.x - 导入错误 : can't import name gcd from fractions

python - Django-admin 在 vi​​rtualenv 中创建了错误的 django 版本

python - 随机遍历所有排列