Вопрос по python – Python с плавающей точкой в преобразовании int

7

Error: User Rate Limit Exceededint(20.0)Error: User Rate Limit Exceeded20Error: User Rate Limit Exceeded

levels = [int(gex_dict[i]) for i in sorted(gex_dict.keys())]

Error: User Rate Limit Exceededgex_dict[i]Error: User Rate Limit Exceeded20.0Error: User Rate Limit Exceeded

"invalid literal for int() with base 10: '20.0'"

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceededgex_dictError: User Rate Limit Exceeded jamylak
Error: User Rate Limit Exceeded langohrschnauze

Ваш Ответ

4   ответа
2

Error: User Rate Limit Exceededint(float(gex_dict[i]))

1

Error: User Rate Limit Exceeded

>>> int(20.0)
20
>>> int('20.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '20.0'

Error: User Rate Limit Exceeded

>>> int(float('20.0'))
20

Error: User Rate Limit Exceeded

levels = [int(float(gex_dict[i])) for i in sorted(gex_dict.keys())]
14

'20.0'Error: User Rate Limit ExceededfloatError: User Rate Limit ExceededintError: User Rate Limit ExceededfloatError: User Rate Limit Exceededint:

>>> int(float('20.0'))
20

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded langohrschnauze
Error: User Rate Limit Exceeded
2

Error: User Rate Limit Exceededgex_dict[i]Error: User Rate Limit Exceeded'20.0'Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

Похожие вопросы