[英]How can i set up credentials as an environmental variable in windows?
我目前正在我的大學從事一個學術項目,我正在嘗試訪問 IEX Cloud API (iexfinance) 以使用 python 進行財務數據提取,但我一直遇到身份驗證錯誤。 當我檢查 package 的文檔時,它建議使用“IEX_TOKEN”將秘密身份驗證密鑰設置為環境變量,以驗證我不知道該怎么做的請求。
另外,我應該注意,我對編程世界很陌生,所以提前感謝您的任何幫助。
這是我使用的腳本片段:
tickerSymbol = input("Ticker Symbol: ")
companyInfo = Stock(tickerSymbol)
stockPrice = companyInfo.get_price()
start = datetime(sy,sm,sd)
end = datetime(ey, em,ed)
historicalPrices = get_historical_intraday(tickerSymbol, start, end)
stockHistoricals = pd.DataFrame(historicalPrices).T
假設您知道秘密身份驗證密鑰。 嘗試:
#import os module in first line of your code
import os
#set the env vairable in 2nd line
os.environ['IEX_TOKEN'] = 'TheSecretAuthenticationKey'
#other imports
...
...
...
...
#remaining code
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.