課程
/后端開發
/Python
/初識Python
請問為什么不可以用 \n 換行?
但是好像可以用""" """ 多行字符串來換行.
可是本頁的測試過不了,
不知這種方法對不對?
2017-05-24
源自:初識Python 4-1
正在回答
L="['Adam',95.5,\n'Lisa',85,\n'Bart',59]"
print L
借鑒了一樓的,這個也可以
Frank86 提問者
qq_下一個末日_0 回復 Frank86 提問者
>>> print 'b\nc\nd\ne\nf\n'
b
c
d
e
f
可以用啊
如果要表示多行字符串,可以用”’…”’表示:
''’Line 1?Line 2?Line 3''’?上面這個字符串的表示方法和下面的是完全一樣的:
‘Line 1\nLine 2\nLine 3’?還可以在多行字符串前面添加 r ,把這個多行字符串也變成一個raw字符串:
r''’Python is created by “Guido”.?It is free and easy to learn.?Let’s start learn Python !'''
L="""['Adam,95.5,
'Lisa',85,
'Bart',59]"""
\n是html的代碼啊
L="""['Adam',95.5,\n'Lisa',85,\n'Bart',59]"""
舉報
學python入門視頻教程,讓你快速入門并能編寫簡單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-05-24
L="['Adam',95.5,\n'Lisa',85,\n'Bart',59]"
print L
借鑒了一樓的,這個也可以
2017-05-24
>>> print 'b\nc\nd\ne\nf\n'
b
c
d
e
f
可以用啊
2017-05-24
如果要表示多行字符串,可以用”’…”’表示:
''’Line 1?
Line 2?
Line 3''’?
上面這個字符串的表示方法和下面的是完全一樣的:
‘Line 1\nLine 2\nLine 3’?
還可以在多行字符串前面添加 r ,把這個多行字符串也變成一個raw字符串:
r''’Python is created by “Guido”.?
It is free and easy to learn.?
Let’s start learn Python !'''
2017-05-24
L="""['Adam,95.5,
'Lisa',85,
'Bart',59]"""
2017-05-24
\n是html的代碼啊
2017-05-24
L="""['Adam',95.5,\n'Lisa',85,\n'Bart',59]"""
print L