本帖最后由 keshun 于 2020-11-10 20:04 编辑
20元求助高手帮忙解决,更换以下网址代码运行出错,两组数据400行要求合并400行不要800行显示,谢谢!
https://www- # ! -*- coding:utf-8
- import pandas as pd
- import requests
- import json, time, re, os
- pd.set_option('display.max_rows', None)
-
- api_url = "https://www"
- html = requests.get(api_url)
- datas = pd.DataFrame()
- sort = 0
- for i in json.loads(html.text)["data"]["asks"]:
- sort += 1
- df_insert = pd.DataFrame(
- {'A1': i[0], 'B1': i[1], 'C1': i[2], 'D1': i[3]}, index=[sort])
- datas = datas.append(df_insert)
- sort = 0
- for i in json.loads(html.text)["data"]["bids"]:
- sort += 1
- df_insert = pd.DataFrame(
- {'A2': i[0], 'B2': i[1], 'C2': i[2], 'D2': i[3]}, index=[sort])
- datas = datas.append(df_insert)
-
- print(datas)
- input("关闭窗口")
复制代码
|