且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将数字字符串转换为数字列表

更新时间:2023-02-03 08:03:16

就这么简单:

在Python2中:

print [int(s) for s in l.split(',')]

,而在Python3中,只需用括号括起来即可:

and in Python3 simply wrapped with a parentheses:

print([int(s) for s in l.split(',')])