#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
阅读更多
个人分类: Python学习
上一篇#Python3 面向对象——转自菜鸟教程
下一篇#Python3 字典 get() 方法
想对作者说点什么? 我来说一句
相关热词

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

关闭
关闭
关闭