What is the easiest way to convert list with str into list with int?

后端 未结 5 536
悲&欢浪女
悲&欢浪女 2020-12-10 02:29

What is the easiest way to convert list with str into list with int in Python? For example, we have to convert [\'1\', \'2\', \'3\']

5条回答
  •  再見小時候
    2020-12-10 03:11

    If It is array and has installed numpy. We can used below code as well.

    import numpy as np
    
    np.array(['1', '2', '3'],dtype=int)
    

提交回复
热议问题