如何將打印語句中的結果寫入csv文件,每次循環運行結果時都要添加到下一行。結果包含一個列表。Python寫入列表到csv
def func_high(i):
swing_low = data_file.iloc[i].Low
date = data_file.iloc[i].Date
while i < len(data_file):
i = i + 1
try :
swing_high = data_file.iloc[i].High
if (swing_high < data_file.iloc[i + 1].High) and (data_file.iloc[i + 1].High > data_file.iloc[i + 2].High):
date_diff = data_file.iloc[i + 1].Date - date
price_diff = data_file.iloc[i + 1].High - swing_low
**print (price_diff/date_diff.days, date, swing_low , data_file.iloc[i + 1].Date, data_file.iloc[i + 1].High, date_diff)**
except IndexError:
pass
continue
謝謝,我喜歡你編輯的。 – user1779646