#textwrap模块的dedent

dedent用来去除用“”“表示输出段落时段落前缩进的空白,使得靠左输出。
例子:

from sys import exit
from random import randint
from textwrap import dedent

print(dedent("""
        erefdfdf
        ererereeeeeeeeeeeeew
        dddddddddddd
        eeeeeeeeeeeeeeee
        eeeeeeeeeeeee
        """))

print("-"*30)

print("""
        ereerdfdferer
        ererereeeeeeeeeeeee
        dddddddddddd
        eeeeeeeeeeeeee
        eeeeeeeeeeeee
        """)

结果print:

>>> runfile('E:/CS/Python/PythonHardWay/ex43.py', wdir='E:/CS/Python/PythonHardWay')

erefdfdf
ererereeeeeeeeeeeeew
dddddddddddd
eeeeeeeeeeeeeeee
eeeeeeeeeeeee

------------------------------

        ereerdfdferer
        ererereeeeeeeeeeeee
        dddddddddddd
        eeeeeeeeeeeeee
        eeeeeeeeeeeee
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页