我认为这应该很容易,但我真的不知道如何以更好的方式编写它,如果你知道请告诉我
#there are some points in text files and was read into a list
s = ['3,4','4,5','6,5','7,8']
#break s element to (x,y) form every element should convert to number type
points = []
for pStr in s:
ss = pStr.split(',')
points.append([int(p) for p in ss])
print(points) #[[3, 4], [4, 5], [6, 5], [7, 8]]
请最好把它写在一行中