numpy.savetxtの周りに小さなラッパーを使用して、ヘッダー名を自動的に生成し、読み取り可能な出力用にある程度インテリジェントな幅の配置を作成します。より基本的な解決策は、この答えにあります。
ドキュメントに示されているように左揃えにするのではなく、幅を指定して出力テキストを中央に揃える方法を知りたいです。
numpy.savetxt
ドキュメントから、私はこの情報を見ます:
Notes ----- Further explanation of the `fmt` parameter (``%[flag]width[.precision]specifier``):
flags:
``-`` : left justify
``+`` : Forces to preceed result with + or -.
``0`` : Left pad the number with zeros instead of space (see width).
width:
Minimum number of characters to be printed. The value is not truncated
if it has more characters.
ドキュメントは、 python mini形式の仕様で、より「網羅的なリソース」を示していますが、そこにある情報は、アライメント情報と互換性がありません。
さまざまな配置オプションの意味は次のとおりです。
Option Meaning
'<' Forces the field to be left-aligned within the available space (this is the default for most objects).
'>' Forces the field to be right-aligned within the available space (this is the default for numbers).
'=' Forces the padding to be placed after the sign (if any) but before the digits. This is used for printing fields in the form ‘+000000120’. This alignment option is only valid for numeric types.
'^' Forces the field to be centered within the available space.
'^'
非互換性は、savetxtが有効なフォーマット文字として受け入れられないためです。出力が中央揃えになるように`numpy.savetxt'でフォーマットを指定する方法に誰かが光を当てることができますか?