python關於\ 符號 連接 代碼 變量 過長符號 換行繼續

這個 ‘\’符號的作用是連接變量或者代碼過長,仔細看下面代碼,理解它的用法:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import MySQLdb

a = "https://blog.51cto.com"\
    "dinghanhua/p/"\
    "9900775.html"
print a

b= """第一行
第二行
第三行"""

print b

c = "thins line is toooooooooooo\
lone"
print "c: ",c

d = "https://blog.51cto.com/\
dinghanhua/p/\
9900775.html"
print "d: ",d

print "thins line is toooooooooooo\
lone"

上面的輸出結果

https://blog.51cto.com/dinghanhua/p/9900775.html
第一行
第二行
第三行
c:  thins line is toooooooooooolone
d:  https://blog.51cto.com/dinghanhua/p/9900775.html
thins line is toooooooooooolone
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章