On Thu, 3 Dec 2020 at 18:26, Ernesto Arbitrio <ernesto.arbit...@gmail.com>
wrote:

> potresti usare qualcosa del tipo:
> print("{0}".format(str(round(x, 1) if x % 1 else int(x)))
>

Oppure:

>>> f"{6:g}"
'6'
>>> f"{6.0:g}"
'6'
>>> f"{6.5:g}"
'6.5'

Ciao.
Marco.
_______________________________________________
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python

Rispondere a