【发布时间】:2020-03-18 02:05:57
【问题描述】:
我是 python 或任何其他编程语言的初学者。我正在尝试学习 python 以 Json 格式请求 API 的数据,然后导出到 google-sheet 以与我的财务数据一起使用。但我的第一步是修复这个输出错误:
import requests
def crypto_price():
response = requests.get('https://api.gdax.com/products/ETH-USD/ticker')
r_json = response.json()
return float(r_json[1]['price'])
print(crypto_price)
正在输出如下内容:
<function crypto_price at 0x7fc257d601e0>
而不是那样:
{"trade_id":55904930,
"price":"117.26",
"size":"0.05016553",
"time":"2020-03-18T01:43:49.023244Z",
"bid":"117.23",
"ask":"117.26",
"volume":"353473.96787048"}
这对我来说很奇怪,因为它只有在我使用“def”时才会发生。
【问题讨论】:
-
您必须调用该函数。添加
()! -
能问一下你的问题和
google-apps-script的标签之间的关系吗? -
@Tenaike,再说一遍,我要导出到谷歌表格。我会尝试做一些脚本
-
感谢您的回复。不幸的是,我无法从您的回复中了解您的目标。这是因为我的英语水平不好。对此我深表歉意。
标签: python google-sheets python-requests