Python textwrap Library - How to Preserve Line Breaks?

后端 未结 8 935
礼貌的吻别
礼貌的吻别 2021-02-04 02:19

When using Python\'s textwrap library, how can I turn this:

short line,

long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
         


        
8条回答
  •  一整个雨季
    2021-02-04 02:59

    try

    w = textwrap.TextWrapper(width=90,break_long_words=False,replace_whitespace=False)
    

    that seemed to fix the problem for me

    I worked that out from what I read here (I've never used textwrap before)

提交回复
热议问题