0
我寫2個功能如何將這些功能合併到一個程序中? (蟒)
第一個讀取文件並以列表給出的行數: 例如: 輸入1,2,3 = 4,5,6 = 7 = 9,10, 11
def read_coordinates():
invoerfile = open("coordinates.txt", "r")
lines = invoerfile.readlines()
for line in lines:
seperate_coordinate_rows = line.split("=")
for seperate_coordinate_row in seperate_coordinate_rows:
print seperate_coordinate_row.split()
輸出: [ 「1,2,3」] [ 「4,5,6」] [ 「7」] [ 「9,10,11」]
並且這個編織2行到彼此:
例如: [ 「1,2,3」] [ 「4,5,6」]變爲[ 「1,4,2,5,3,6」]
def Weave_number_rows(row1,row2): #enter 2 rows of numbers as lists
l1 = row1
l2 = row2
woven = sum(zip(l1, l2),())
print woven
怎能這些2一起工作,python evrytime將現有的行編織到下一行?