[Python] formatting output of gvar

Discussão em 'Python' iniciado por Stack, Dezembro 19, 2024.

  1. Stack

    Stack Membro Participativo

    I use the gvar library in python. This example, taken from the documentation gives an error:

    >>> import gvar
    >>> x = gvar.gvar(3.14159, 0.0236)
    >>> print(f'{x:.2g}', f'{x:.3f}', f'{x:.4e}', f'{x:.^20.2g}')
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "src/gvar/_gvarcore.pyx", line 92, in gvar._gvarcore.GVar.__format__
    ValueError: Unknown format code 'g' for object of type 'str'
    >>>


    The version of gvar I am using is 11.11.12.

    How should I fix the code with this version of gvar?

    Continue reading...

Compartilhe esta Página