我想知道在每种方法结束时使用return是否有任何意义 如果不这样做,有没有下降或上升?
f.e。
for i in range(0, len(__modes_names)): #run through all available csv files
with open(__csv_file_distance_arrays.format(__modes_names[i]), "r") as File:
csv_reader = csv.DictReader(File, delimiter=";")
for line in csv_reader: #run through all lines
for column in range(1, __numberoftps+1): #run through all columns
if line["from\\to"] == __tps[column-1].get_name(): #compare names of origin and destination
pass
else:
for w in __ways: #run through all ways
if w.get_name() == "way_{}_{}".format(line["from\\to"], __tps[column-1].get_name()): #if way matches,
w.get_modes()[i].set_distance(int(line[__tps[column-1].get_name()])) #assign distance to way
else:
pass
在这种情况下,我不需要返回值,因为在程序的这一点上,我已经实例化了一个对象列表,并调用这些对象的方法来保存我从CSV文件中读取的变量。