python使用技巧(三十二):将整个list都是数值的字符串转为正常的数值list--->案例:str = “[1,2,3,5,7,10]“
源码实现:strs="[1,2,3,5,7,10]"print(type(strs[0]))ss=strs[1:-1]ss=list(ss)print(ss)foriinss:ifi==",":ss.remove(i)#print(ss)int_list=[int(x)forxinss]print(int_list)运行结果:['1',',','2',',','3',',','5',',','7'