>  Q&A  >  본문

python - Django 中字段值为unicode类型,想要转换成int类型报错?

water_alarm_source['analog_value'] = int(str(i['analog_value1']))/1000
其中 i['analog_value1'] 取出来的类型为 unicode,想要转换成int类
错误:

 "data": "invalid literal for int() with base 10: '100.0'"
高洛峰高洛峰2721일 전473

모든 응답(3)나는 대답할 것이다

  • 高洛峰

    高洛峰2017-04-18 10:20:09

    float()

    회신하다
    0
  • 黄舟

    黄舟2017-04-18 10:20:09

    water_alarm_source['analog_value'] = float(str(i['analog_value1']))//1000

    회신하다
    0
  • PHP中文网

    PHP中文网2017-04-18 10:20:09

    으아아아

    회신하다
    0
  • 취소회신하다