0

Есть обменник кроптовалют. И при вводе количества допустим 0,00123 выходит ошибка

File "C:\Users\adminkropal\Desktop\kropal\make_bot_great_again.py", line 612, in exchange_wallet
res = calculator(float(message.text), data.get('currency'), "RUB")

Я так понял что у меня только настроено на 0.00123 с "." а нужно сделать что-бы было "," - запятую.

Вот код

@dp.message_handler(state=ExchangeForm.amount, content_types=types.ContentTypes.TEXT)
async def exchange_wallet(message: types.Message, state: FSMContext):
data = await state.get_data()
res = calculator(float(message.text), data.get('currency'), "RUB")
1
  • string = "0,666" string = string.replace(",", ".") Только проверку осуществите на наличие ","
    – Volkodaff
    21 апр 2021 в 21:33

1 ответ 1

0

В общем сделал так res = calculator(float((message.text).replace(',','.')), data.get('currency'), "RUB") replace() помог.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.