0
格式化我有一個Python腳本,看起來像這樣:字符串在輸出
print "Header 1"
print "\t Sub-header 1"
print "\t\t (*) Sentence 1 begins here and goes on... and ends here."
的句子被印刷在與同類格式的環路,它給終端這樣的輸出:
Header 1
Sub-header 1
(*) Sentence 1 begins here and goes on...
and ends here.
(*) Sentence 2 begins here and goes on ...
and ends here.
.
.
.
有什麼辦法可以使格式如下? :
Header 1
Sub-header 1
(*) Sentence 1 begins here and goes on...
and ends here.
(*) Sentence 2 begins here and goes on ...
and ends here.
.
.
.
我使用print'print'('Text_1 =%-20s | Text_2 =%0s | Text_3 =%6s \ n')%('Here','Here_2','Here_3')'在屏幕上打印。這對你有幫助嗎? (運行它) – SnuKies
確實有一種方法可以根據需要進行格式設置,但正確的方法可能取決於您現有的代碼。你能解釋一下這個格式是如何完成的嗎? – Tryph
@SnuKies:謝謝,但對我的情況沒有幫助。由於句子太長,格式仍然在終端中斷。 –