📌  相关文章
📜  python将字符串列表转换为整数列表 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:04.107000             🧑  作者: Mango

代码示例4
# Example usage using list comprehension:
# Say you have the following list of lists of strings and want integers
x = [['565.0', '575.0'], ['1215.0', '245.0'], ['1740.0', '245.0']]
list_of_integers = [[int(float(j)) for j in i] for i in x]

print(list_of_integers)
--> [[565, 575], [1215, 245], [1740, 245]]

# Note, if the strings don't have decimals, you can omit float()