'for'루프의 연속을 설정하고이 결과로 3 개의 값을 결정할 수 있습니다. 이제 3 개의 값을 목록에 저장하려고합니다. 다른 목록의 목록에 값 추가
output = [] # creates empty list
k = 0
for i in range(len(GPS[0])-1): # for loop through 1 column of GPS .csv this is the time
for j in range(len(Data[0])-1): # for loop through 1st column of Data .csv this is the time
if GPS[1,i] == Data[1,j]: # if loop, so if time in GPS = time in Data
delta = i-j # finds the difference between values
#print(i,j, delta) # prints row in i that matches row in j, and also the difference between them
#print(GPS[1,i],Data[1,j]) # prints the Height from GPS and time from Data
output[k] = output.append(GPS[1,i], GPS[0,i], Data[1,j])
k=k+1
print(output)
은 기본적으로 내가 출력이 목록은 3 개 값
GPS[1,i]
,
GPS[0,i]
및
Data[0,j]
을 포함 할 것을 권장합니다 이것은 내가 지금까지 시도 한 것입니다. 내가 APPEND를 사용하려고했지만 난 아무데도 그것으로 얻을 수없는 것, 내가 얻을 모두가 '없음'
마 세 가지 요소를 목록에 추가하거나 세 개의 요소가있는 ** 튜플 **을 목록에 추가 하시겠습니까? –
'append()'는 목록을 수정하고'None'을 반환합니다. 따라서'output [k] = output.append (GPS [1, i], GPS [0, i], Data [1, j] ])'사실, 당신은 실제로'output [k] = None'을 설정하고 있습니다. – asongtoruin
3 원소를리스트에 추가하면 나중에 개별적으로 호출 할 수 있습니다. –