如何自動換行長python字符串以便它們正確打印?正確包裝長python字符串以進行optparse
具體而言,我想添加幫助字符串optparse,我想能夠輕鬆修改。
我已經找到了解決長字符串,其中沒有一個讓我做在Emacs使用MQ或類似的改變後補充的幾種方法:在結果
p.add_option('-a', help = "this is my\
long help text")
力換行和不允許回填
p.add_option('-a', help = "this is my "
"long help text")
格式正確,但不允許補充
p.add_option('-a', help = '''
this is my
long help text
''')
格式不正確,但允許補充
p.add_option('-a', help = dedent('''
this is my
long help text
'''))
是我已經找到了最好的選擇,格式幾乎正確,允許在字符串的開頭補充,但會導致額外的空間。
什麼是''refilling''..我不熟悉它。 – mgilson 2013-04-10 14:18:02
我不確定術語是否完美,我只是指在編輯之前填充已填充的文本,我從[填充模式](http://www.emacswiki.org/emacs/RefillMode) 。 – kaveish 2013-04-10 14:23:45
是的,但「填充文本」是什麼意思? – mgilson 2013-04-10 14:25:01