如何在python中将字符串列表转换为整数 [英] How to convert a string list into an integer in python
本文介绍了如何在python中将字符串列表转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的python脚本中,我有:
In my python Script I have:
user = nuke.getInput("Frames Turned On")
userLst = [user]
print userLst
结果:
['12,33,223']
<我想知道如何删除列表中的'
,或以某种方式将其转换为int?
I was wondering How I would remove the '
in the list, or somehow convert it into int?
推荐答案
使用 split()
以逗号分割,使用 int()
转换为整数:
Use split()
to split at the commas, use int()
to convert to integer:
user_lst = map(int, user.split(","))
这篇关于如何在python中将字符串列表转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文