如何在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(","))