嗨,我遇到此错误消息的问题.我是Python的新手,这个Python2和Python3很麻烦.我不知道该怎么做,错误信息如下所示.
Using Ticker: AAPL
Traceback (most recent call last):
File "realtime.py", line 18, in <module>
r=requests.get(auth_url, headers={"Authorization": "Basic %s" % base64.b64encode(os.environ['INTRINIO_USER'] + ":" + os.environ['INTRINIO_PASSWORD'])})
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\base64.py", line 58, in b64encode
encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'str'
Run Code Online (Sandbox Code Playgroud)
我使用的代码如下所示.
import websocket
import _thread
import time
import requests
import base64
import json
import sys
import os
from requests.auth import HTTPBasicAuth
try:
print ("Using Ticker: " + str(sys.argv[1]))
except:
print ("Please include ticker as first argument")
sys.exit() …Run Code Online (Sandbox Code Playgroud) 我收到一条错误消息,但不知道如何继续,错误消息显示在下面。我已经下载了它运行所需的所有工具,但密钥似乎有问题。我已经正确输入了它们,但是为了保持我的帐户的私密性,我已隐藏帐户用户名和密码。提前致谢
C:\Users\User\Downloads\real-time-intrinio-python-master\real-time-intrinio-python-master> python realtime.py AAPL
Using Ticker: AAPL
Traceback (most recent call last):
File "realtime.py", line 18, in <module>
r=requests.get(auth_url, headers={"Authorization": "Basic %s" % base64.b64encode(os.environ['myUsername'] + ":" + os.environ['myPassword'])})
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\os.py", line 669, in __getitem__
raise KeyError(key) from None
KeyError: 'myUsername'
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码,第 18 行是“r=requests.get(auth_url, headers...”
import websocket
import _thread
import time
import requests
import base64
import json
import sys
import os
from requests.auth import HTTPBasicAuth
try:
print ("Using Ticker: " + str(sys.argv[1]))
except:
print ("Please include ticker as first argument") …Run Code Online (Sandbox Code Playgroud)