【Python】Python的單雙引號

Python真的爽,單雙引號的運用太舒服了

在Python中,使用單引號或雙引號是沒有區別的,都可以用來表示一個字符串


1.單雙引號都可以用來表達

輸入:

print("Hello1")
print('Hello2')

輸出:

Hello1
Hello2

 

2.還可以一起用,來避免混淆

輸入:

print('test the " 111')
print("test the ' 222")

輸出:

test the " 111
test the ' 222

 

3.也可以通過轉義字符來避免混淆

輸入:

print("test the \" 333")
print('test the \' 444')

輸出:

test the " 333
test the ' 444

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章