【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

 

 

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