[[146 300]][[131 297]] [[132 298]][[147 287]][[143 284]] [[144 285]]
要怎麼變成
['146', '300']
['131', '297', '132', '298']
['147', '287']
['143', '284', '144', '285']
Code
a = "[[146 300]][[131 297]] [[132 298]][[147 287]][[143 284]] [[144 285]]".split("][")
for i in range(len(a)):
a[i]= a[i].replace("[","").replace("]","")
locals()["list_" + str(i+1)] = a[i].split(" ")
print("List_{} = {}".format(i+1, locals()["list_" + str(i+1)]))
Result
List_1 = ['146', '300']
List_2 = ['131', '297', '132', '298']
List_3 = ['147', '287']
List_4 = ['143', '284', '144', '285']