我正在尝试通过API绘制股票的财务信息。
我无法在代码中提供输入信息以评估不同的股票。
当我输入输入代码时,我得到消息:
TypeError: 'str' object is not callable.
这是我正在阐述的代码:
import requests
main_api = 'https://financialmodelingprep.com/api/v3/company/profile'
my_request = input('Which stock you look for? ')
url = main_api + '/' + my_request
print(url)
request = requests.get(url,
headers={
"X-RapidAPI-Host": "investors-exchange-iex-trading.p.rapidapi.com",
"X-RapidAPI-Key":
"ab295550bemsh717b12e1a0e93e8p180b21jsn9e636c0d25ef"
}
)
request_json = request.json()
print(request_json)
price = request_json['profile'][0]['price']
print("Today value:", price)
感谢您的帮助或建议。