代码示例
1、
num = input()
nums = list(map(int,num))
print(nums)】
输出:[1, 2, 3]
2、
num = input()
nums = list(map(int,num.split()))
print(nums)
输出 :[123]
#其中split:split() 通过指定分隔符对字符串进行切片,如果参数 num 有指定值,则仅分隔 num 个子字符串。
语法:str.split(str="", num=string.count(str))
关于python中数字字符串转变数组的方法
最新推荐文章于 2022-10-11 09:20:11 发布