gpt4 book ai didi

python - 我使用 format() 内置函数的错误消息

转载 作者:太空宇宙 更新时间:2023-11-04 02:51:57 26 4
gpt4 key购买 nike

这是我的代码和错误信息:

>>> message = ‘The price of this {0:s} laptop I {1:d} USD and the exchange rate is {2:4.2f} USD to 1 EUR’.format(‘Apple’, 1299, 1.23342342)
SyntaxError: invalid character in identifier

根据我所关注的书,我的代码是正确的。我应该提到,单词“The”以粉红色突出显示,单词“and”“is”都显示为黄色。

最佳答案

您使用了错误的引号字符,您需要使用 '"

message = 'The price of this {0:s} laptop I {1:d} USD and the exchange rate is {2:4.2f} USD to 1 EUR'.format('Apple', 1299, 1.23342342)

关于python - 我使用 format() 内置函数的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43600652/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com