我有这个代码
from opensky_api import OpenSkyApi
api = OpenSkyApi()
states = api.get_states(bbox=(51.3500, 51.5900, -0.6342, -0.2742))
for s in states.states:
lat = s.latitude
print(lat)
输出看起来像这样
51.4775
51.4589
51.4774
51.4774
如何使输出看起来像这样?
[51.4775, 51.4589, 51.4774, 51.4774]
最佳答案
试试这个:
from opensky_api import OpenSkyApi
api = OpenSkyApi()
states = api.get_states(bbox=(51.3500, 51.5900, -0.6342, -0.2742))
arr = []
for s in states.states:
arr.append(s.latitude)
print(arr)
关于python - 如何将循环的输出发送到 python 列表?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50426378/