-
-
Save yuyueugene84/59ad7b94158ab057dfef9d53c80057b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 用顔色標記漲跌 | |
for i in range(3, 100): | |
daily_return = tsmc_sheet.cells(i, 3).value | |
# 若該筆資料的日報酬率是上漲的 (大於 0) | |
if daily_return > 0: | |
# 就把該儲存格的底色換成紅色 | |
# (255, 0, 0) 三個數字是代表 RGB, 也就是紅、綠、藍三種顔色的强度 | |
tsmc_sheet.cells(i, 3).color = (255, 0, 0) | |
# 若該筆資料的日報酬率是下跌的 (小於 0) | |
elif daily_return < 0: | |
# 就把該儲存格的底色換成綠色 | |
tsmc_sheet.cells(i, 3).color = (0, 255 , 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment