# 錯(cuò)誤示例
str = hello
format()
方法或者f-string來(lái)實(shí)現(xiàn),如果直接將變量放在字符串中,會(huì)導(dǎo)致錯(cuò)誤。# 錯(cuò)誤示例
name = "Alice"
print("Hello, name") # 應(yīng)該是 print("Hello, " + name)
# 錯(cuò)誤示例
print('It's a sunny day.') # 應(yīng)該是 print("It's a sunny day.")
# 錯(cuò)誤示例
print("Hello\nWorld") # 應(yīng)該是 print("Hello\\nWorld")
# 錯(cuò)誤示例
text = "Hello, World"
print(text.uppercase()) # 應(yīng)該是 print(text.upper())
# 錯(cuò)誤示例
text = "Hello"
if text == True: # 應(yīng)該是 if text == "True":
print("String is True")