① 單引號和雙引號主要用來表示字符串
# 單引號''
astr = 'Python'
print(type(astr)) # <class 'str'># 雙引號""
bstr = "Python"
print(type(bstr)) # <class 'str'>
str1 = 'I\'m a big fan of Python.'
print(str1) # I'm a big fan of Python.str2 = "We all know that 'A' and 'B' are two capital letters."
print(str2) # We all know that 'A' and 'B' are two capital letters.str3 = 'The teacher said: "Practice makes perfect" is a very famous proverb.'
print(str3) # The teacher said: "Practice makes perfect" is a very famous proverb.
當你用單引號' '定義字符串的時候,它就會認為你字符串里面的雙引號" "是普通字符,從而不需要進行轉義;反之當你用雙引號" "定義字符串的時候,它就會認為你字符串里面的單引號' '是普通字符也無需進行轉義