处理引号和撇号
撇号 (')
在 Python 中表示一个字符串。为了让 Python 知道不是在处理字符串,必须使用 Python 转义字符 ()。因此撇号在 Python 中表示为 '
。与处理撇号不同,Python 中有很多处理引号的方法。它们包括以下内容:
# 1. Represent string with single quote (`""`) and quoted statement with double quote (`""`)
quotes_one = '"Friends don\'t let friends use minibatches larger than 32" - Yann LeCun'
print(quotes_one)
# 2. Represent string with double quote `("")` and quoted statement with escape and double quote `(\"statement\")`
quotes_two = "\"Friends don\'t let friends use minibatches larger than 32\" - Yann LeCun"
print(quotes_two)
# 3. Represent string with triple quote `("""""")` and quoted statment with double quote ("")
quote_three = """"Friends don\'t let friends use minibatches larger than 32" - Yann LeCun"""
print(quote_three)
Output:
"Friends don't let friends use minibatches larger than 32" - Yann LeCun
"Friends don't let friends use minibatches larger than 32" - Yann LeCun
"Friends don't let friends use minibatches larger than 32" - Yann LeCun