Python中文
首页
教程
问答
标签
搜索
登录
注册
python中的API调用没有结果
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>Python中的API调用不返回任何结果。它以代码0退出,但没有显示任何内容。有什么我不知道的吗?我还是Python新手,从YouTube教程中获得了代码。我正在使用自己的API密钥。代码如下:</p> <pre><code>#!/usr/bin/env python #Learn how this works here: http://youtu.be/pxofwuWTs7c import urllib.request import json locu_api = 'XXXXXXXXXXXX' def locu_search(query): api_key = locu_api url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key locality = query.replace(' ', '%20') final_url = url + "&locality=" + locality + "&category=restaurant" json_obj = urllib2.urlopen(final_url) data = json.load(json_obj) for item in data['objects']: print (item['name'], item['phone']) </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>您的脚本<code>def</code>调用函数<code>locu_search</code>,但您没有调用它;因此,脚本成功终止—没有成功执行任何有价值的操作。你知道吗</p> <p>您需要在定义函数后调用它,例如:</p> <pre><code>def locu_search(query): #snip locu_search('San Francisco') </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何将python输出重定向到python控制台和Windows中的文本文件
4 回答
如何将Python运行时嵌入运行在Windows上的R包中
2 回答
如何将python进程作为另一个Windows us运行
6 回答
如何将Python进程的输出用Python管道传输?
1 回答
如何将Python进程的输出重定向到Rust进程?
3 回答
如何将python连接到Azure云并创建Azure数据工厂
10 回答
如何将Python连接到Db2
4 回答
如何将python连接到IBMDB2?
6 回答
如何将Python连接到microsoftaccess数据库文件?
10 回答
如何将python连接到MySQL服务器
3 回答
如何将Python连接到Node.js?
7 回答
如何将python连接到Oracle Application Express
1 回答
如何将Python连接到PostgreSQL
8 回答
如何将Python连接到Postgres服务器?
5 回答
如何将Python连接到SAS Enterprise Guide(EG)服务器
5 回答
如何将Python连接到Spark会话并保持RDDs的Ali
6 回答
如何将python连接到sqlite3并在上填充多行
9 回答
如何将python连接到使用docker运行的cassandra
8 回答
如何将python退格应用于字符串
2 回答
如何将python逻辑应用到tkinter GUI中?这是一个简单的GET请求程序
1 回答