我尝试使用f-string格式化字符串,但它总是会说语法错误或输入错误。
def say_hello(name, feeling): print(f "Hello {name} {feeling}") say_hello('Tony', 'Grumpy')
我在做什么错?
只是您的print语句的语法无效
print(f"Hello {name} {feeling}")
代替
print(f "Hello {name} {feeling}")