相关疑难解决方法(0)

给字符错误的f字符串?

我在这里收到了我的Atom阅读器的错误消息,其中建议第一个print.(f"message")是发送错误:

File "/Users/permanentmajority/Desktop/Coding/learnpythonbook.py", line 75
    print(f"Let's talk about {my_name}.")
                                       ^
SyntaxError: invalid syntax
[Finished in 0.077s]
Run Code Online (Sandbox Code Playgroud)

码:

my_name = 'Zed A. Shaw'
my_age = 35 # not a lie
my_height = 74 # inches
my_weight = 180 #lbs
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Brown'

print(f"Let's talk about {my_name}.")
print(f"He's {my_height} inches tall.")
print(f"He's {my_weight} pounds heavy.")
print("Actually that's not too heavy.")
print(f"He's got {my_eyes} eyes and {my_hair} hair.")
print(f"His teeth are usually {my_teeth} depending on …
Run Code Online (Sandbox Code Playgroud)

python syntax-error python-2.x f-string

10
推荐指数
3
解决办法
2万
查看次数

python中的F字符串前缀给出语法错误

我有一个名为method的变量,它的值是POST,但是当我尝试运行时,print(f"{method} method is used.")它会在最后一个双引号处给出语法错误,但我找不到它为什么会这样做的原因.我使用的是python 3.5.2.

python string

3
推荐指数
1
解决办法
5722
查看次数

标签 统计

python ×2

f-string ×1

python-2.x ×1

string ×1

syntax-error ×1