Python Type Conversion

前端 未结 3 995
Happy的楠姐
Happy的楠姐 2021-01-11 18:23

Whats the best way to convert int\'s, long\'s, double\'s to strings and vice versa in python.

I am looping through a list and passing longs to a dict that should be

3条回答
  •  爱一瞬间的悲伤
    2021-01-11 18:35

    To convert from a numeric type to a string:

    str(100)
    

    To convert from a string to an int:

    int("100")
    

    To convert from a string to a float:

    float("100")
    

提交回复
热议问题