Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
感谢所有帮助,但我阅读了文档并找到了答案
如果它是您想要或描述的列表,您只需将字符串转换为整数。使用内置地图对您有用
>>> some_list = ['1','2','3','4'] >>> map(int, some_list) [1, 2, 3, 4]
等效的列表理解解决方案是
>>> [int(e) for e in some_list] [1, 2, 3, 4]