Python - Convert partial sublist's elements into int

后端 未结 1 1824
北恋
北恋 2021-01-15 18:40

Suppose you have a list like:

[[\"a\", \"1\", \"2\", \"3\"], [\"b\", \"4\", \"5\", \"6\"], [\"c\", \"7\", \"8\", \"9\"]]

And I want to conv

相关标签:
1条回答
  • 2021-01-15 19:27

    If you want to convert the lists inplace, your code is good enough.

    BTW, the list comprehension can be replaced with map:

    l[1:4] = map(int, l[1:4])
    
    0 讨论(0)
提交回复
热议问题