0

textwrap.fill は手動で入力されたテキスト、つまり print("(Really long string)") で機能しますが、csv ファイルから入力されたクラスから印刷すると、予期しない結果が生じます。

例えば:

print(item.name,":",(textwrap.fill(item.description)) 

私は以下を取得します:

 Hide Armor : This crude armor consists of thick furs and hides. It is commonly
worn
by barbarian tribes, evil humanoids, and other folk who lack access to
the tools and materials needed to create better armor. 

何か案は?CSV にはまだ改行がありません。

CSV の行は次のとおりです。

Hide Armor,10,12 + Dex modifier (max 2),-,-,20 lb.,"This crude armor consists of thick furs and hides. It is commonly worn by barbarian tribes, evil humanoids, and other folk who lack access to the tools and materials needed to create better armor.",Medium

それが一行です。

ランダムな改行を削除するアイデアはありますか? 出力の先頭にランダムな空白を入れることはできますか? textwrap モジュールを使用していない場合でも、その空白がどこから来て表示されるのかわかりません。

4

1 に答える 1