fork download
  1. S = "1234"
  2. # 直接遍历字符串,每个字符转整数
  3. L = [int(x) for x in S]
  4. print(L)
Success #stdin #stdout 0.07s 7996KB
stdin
Standard input is empty
stdout
[1, 2, 3, 4]