file = ['[1,2,3],[4,5,6],[7,8,9]']
data = file[0]

number = []
alist = []
count = 0 
i = 0  


char = ['[', ',', ']']

while i < len(data):
    if data[i] in char:
        i += 1
        
    elif count < 3:
        alist.append(int(data[i]))
        count += 1
        i += 1 
    
    if count == 3:
        number.append(alist)
        alist = []
        count = 0 

print(number)

输出:number = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

相关文章:

  • 2021-08-07
  • 2021-04-06
  • 2021-12-26
  • 2021-12-27
  • 2022-02-08
  • 2022-12-23
  • 2021-08-23
猜你喜欢
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
相关资源
相似解决方案