
52
|
第
5
章
随空格,则换行符同样会被保留:
>>> poem2 = '''I do not like thee, Doctor Fell.
... The reason why, I cannot tell.
... But this I know, and know full well:
... I do not like thee, Doctor Fell.
... '''
>>> print(poem2)
I do not like thee, Doctor Fell.
The reason why, I cannot tell.
But this I know, and know full well:
I do not like thee, Doctor Fell.
>>>
顺便说一句,
print()
的输出和交互式解释器执行的自动回显之间是有区别的:
>>> poem2
'I do not like thee, Doctor Fell.\n The reason why, I cannot tell.\n But
this I know, and know full well:\n I do not like thee, Doctor Fell.\n'
print()
会剥离字符串中的引号,只打印其内容。这是专供人类用户的输出。它有助于在
每个打印项之间加入空格,以及在行尾添加换行符:
>>> print('Give', "us", '''some''', """space""") ...