我正在尝试从RESTful服务填充电子表格,有时候没有这样的属性,所以我在电子表格中得到"未定义",脚本停止并发出错误.我不知道如何处理它,或跳过"未定义"部分.
这是json中的示例查询
{
"rel": "self",
"url": "https://www.sciencebase.gov/catalog/items?max=2&s=Search&q=project+
2009+WLCI&format=json&fields=title%2Csummary%2Cspatial%2Cfacets",
"total": 65,
"nextlink": {
"rel": "next",
"url": "https://www.sciencebase.gov/catalog/items?max=2&s=
Search&q=project+2009+WLCI&format=json&fields=title%2Csummary%2
Cspatial%2Cfacets&offset=2"
},
"items": [
{
"link": {
"rel": "self",
"url": "https://www.sciencebase.gov/catalog/item/
4f4e4ac3e4b07f02db67875f"
},
"id": "4f4e4ac3e4b07f02db67875f",
"title": "Decision-Making and Evaluation - Social and Economic
Evaluation Supporting Adaptive Management for WLCI",
"summary": "Provide information on the social and economic environment
for the WLCI area and provide context for the biological and physical
aspects of this project.",
"spatial": {
"representationalPoint": [
-108.585,
42.141
]
},
"facets": …Run Code Online (Sandbox Code Playgroud) 我仍然试图理解递归和我期望打印的代码和实际打印的内容是不同的.
所以这里的代码基于我在youtube上找到的一个简单例子,
def count(n):
if n > 0:
print "Count 1", ", ", n
count(n - 1)
print "Count 2", ", ", n
else:
print "Done"
count(1)
Run Code Online (Sandbox Code Playgroud)
这就是它的印刷品,
数1,1
完成
数量2,1
我的期望是什么
数1,1
完成
完成
我的理解(当然是错误的)是count(1)(对于外部计数函数)将被调用,因为1大于0将打印1,然后count(1 - 1)(内部计数函数)将调用count(0)(外部计数功能),因为0不大于1,这将打印完成.然后我认为从count(1 - 1)返回(内部计数函数)也将返回Done,因为没有其他n值输入到内部count()中.我不知道怎么做一次打印,1次打印两次???