Setting the fmt option in numpy.savetxt

后端 未结 2 1984
攒了一身酷
攒了一身酷 2020-12-05 02:29

I am looking at the numpy.savetxt, and am stuck at the fmt option.

I tried looking at here and also the reference in the link below all th

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 03:01

    This link might be helpful.

    From the link:

    format_spec ::=  [[fill]align][sign][#][0][width][,][.precision][type]
    fill        ::=  
    align       ::=  "<" | ">" | "=" | "^"
    sign        ::=  "+" | "-" | " "
    width       ::=  integer
    precision   ::=  integer
    type        ::=  "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
    

    Width is a decimal integer defining the minimum field width. If not specified, then the field width will be determined by the content.

    When no explicit alignment is given, preceding the width field by a zero ('0') character enables sign-aware zero-padding for numeric types. This is equivalent to a fill character of '0' with an alignment type of '='.

    The precision is a decimal number indicating how many digits should be displayed after the decimal point for a floating point value formatted with 'f' and 'F', or before and after the decimal point for a floating point value formatted with 'g' or 'G'. For non-number types the field indicates the maximum field size - in other words, how many characters will be used from the field content. The precision is not allowed for integer values.

提交回复
热议问题