Skip to content

Instantly share code, notes, and snippets.

@yuyueugene84
Created May 18, 2018 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuyueugene84/59ad7b94158ab057dfef9d53c80057b5 to your computer and use it in GitHub Desktop.
Save yuyueugene84/59ad7b94158ab057dfef9d53c80057b5 to your computer and use it in GitHub Desktop.
# 用顔色標記漲跌
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