# 错误示例
str = hello
format()
方法或者f-string来实现,如果直接将变量放在字符串中,会导致错误。# 错误示例
name = "Alice"
print("Hello, name") # 应该是 print("Hello, " + name)
# 错误示例
print('It's a sunny day.') # 应该是 print("It's a sunny day.")
# 错误示例
print("Hello\nWorld") # 应该是 print("Hello\\nWorld")
# 错误示例
text = "Hello, World"
print(text.uppercase()) # 应该是 print(text.upper())
# 错误示例
text = "Hello"
if text == True: # 应该是 if text == "True":
print("String is True")