输出结果问题

来源:3-2 如何实现可迭代对象和迭代器对象(2)

梦想家小可

2018-01-21

import requests

def getweather(city):
r = requests.get(u'http://wthrcdn.etouch.cn/weather_mini?city=' + city)
data = r.json()['data']['forecast'][0]
return '%s: %s, %s' % (city,data['low'], data['high'])

print(getweather('北京'))
print(getweather('南京'))

代码就是老师的原始代码,为什么我这里的结果是这样的:

{0, 1, 2, 3, 6, 7, -10, -9, -7}
{0, 3, 6, -9}
北京: 低温 -5℃, 高温 0℃
南京: 低温 3℃, 高温 9℃

python版本3.6,IDE是vs code。集合里的数字每次都会变化。

想知道这两个集合是怎么出现的和出现的原因。

写回答

1回答

程序员硕

2018-02-07

哪个集合?


0
0

Python高效编程技巧实战

精选50个Python案例,源自实战,全面提升Python编程能力

2582 学习 · 360 问题

查看课程