本帖最后由 头发 于 2021-1-4 15:57 编辑
ARRFUTURESNODES = {
czce : ['郑州商品交易所', ['PTA', 'pta_qh', '16'],['菜油', 'czy_qh', '18'], ['菜籽', 'ycz_qh', '18'], ['菜粕', 'czp_qh', '18'],['动力煤', 'dlm_qh', '18'],
['强麦', 'qm_qh', '3'],['粳稻', 'jdm_qh', '3'], ['白糖', 'bst_qh', '15'], ['棉花', 'mh_qh', '7'], ['早籼稻', 'zxd_qh', '23'], ['郑醇', 'zc_qh', '27'],['玻璃', 'bl_qh', '27'],['晚籼稻','wxd_qh','27'],['硅铁','gt_qh','27'],['锰硅','mg_qh','27'], ['棉纱', 'ms_qh', '9'], ['鲜苹果', 'xpg_qh', '27'], ['红枣', 'hz_qh', '27'],['尿素', 'ns_qh', '27'],['纯碱', 'cj_qh', '27'],['短纤', 'pf_qh', '27']],
dce : ['大连商品交易所', ['PVC', 'pvc_qh', '24'], ['棕榈', 'zly_qh', '0'], ['豆二', 'de_qh', '10'], ['豆粕', 'dp_qh', '9'], ['铁矿石', 'tks_qh', '9'],['鸡蛋', 'jd_qh', '9'],
['塑料', 'lldpe_qh', '2'],['PP', 'jbx_qh', '2'],['纤维板', 'xwb_qh', '2'],['胶合板', 'jhb_qh', '2'], ['豆油', 'dy_qh', '14'], ['玉米', 'hym_qh', '12'], ['豆一', 'dd_qh', '8'],['焦炭', 'jt_qh', '26'],['焦煤', 'jm_qh', '26'],['玉米淀粉', 'ymdf_qh', '26'],['乙二醇', 'yec_qh', '26'], ['粳米', 'gm_qh', '26'], ['苯乙烯', 'byx_qh', '30']],
shfe : ['上海期货交易所', ['燃油', 'ry_qh', '13'], ['原油', 'yy_qh', '30'], ['沪铝', 'lv_qh', '1'], ['橡胶', 'xj_qh', '4'], ['沪锌', 'xing_qh', '17'],
['沪铜', 'tong_qh', '5'], ['黄金', 'hj_qh', '19', 'futures.fu_dig2'], ['螺纹钢', 'lwg_qh', '21'], ['线材', 'xc_qh', '22'],
['沪铅','qian_qh','25'],['白银','by_qh','25'],['沥青','lq_qh','25'],['热轧卷板','rzjb_qh','14'],['沪锡','xi_qh','21'],['沪镍','ni_qh','21'], ['纸浆','zj_qh','21'], ['20号胶','ehj_qh','21'], ['不锈钢','bxg_qh','21'], ['低硫燃料油','lu_qh','21'], ['国际铜','bc_qh','21']],
};
如何将嵌套列表中的中间的数据爬出来存进一个新列表中呀???如加红的字体所示(不是指爬红色字体)
币不多,以表心意
改了一下楼上的代码,输出效果好多了 ARRFUTURESNODES = {
'czce' : ['郑州商品交易所', ['PTA', 'pta_qh', '16'],['菜油', 'czy_qh', '18'], ['菜籽', 'ycz_qh', '18'], ['菜粕', 'czp_qh', '18'],['动力煤', 'dlm_qh', '18'],
['强麦', 'qm_qh', '3'],['粳稻', 'jdm_qh', '3'], ['白糖', 'bst_qh', '15'], ['棉花', 'mh_qh', '7'], ['早籼稻', 'zxd_qh', '23'], ['郑醇', 'zc_qh', '27'],['玻璃', 'bl_qh', '27'],['晚籼稻','wxd_qh','27'],['硅铁','gt_qh','27'],['锰硅','mg_qh','27'], ['棉纱', 'ms_qh', '9'], ['鲜苹果', 'xpg_qh', '27'], ['红枣', 'hz_qh', '27'],['尿素', 'ns_qh', '27'],['纯碱', 'cj_qh', '27'],['短纤', 'pf_qh', '27']],
'dce' : ['大连商品交易所', ['PVC', 'pvc_qh', '24'], ['棕榈', 'zly_qh', '0'], ['豆二', 'de_qh', '10'], ['豆粕', 'dp_qh', '9'], ['铁矿石', 'tks_qh', '9'],['鸡蛋', 'jd_qh', '9'],
['塑料', 'lldpe_qh', '2'],['PP', 'jbx_qh', '2'],['纤维板', 'xwb_qh', '2'],['胶合板', 'jhb_qh', '2'], ['豆油', 'dy_qh', '14'], ['玉米', 'hym_qh', '12'], ['豆一', 'dd_qh', '8'],['焦炭', 'jt_qh', '26'],['焦煤', 'jm_qh', '26'],['玉米淀粉', 'ymdf_qh', '26'],['乙二醇', 'yec_qh', '26'], ['粳米', 'gm_qh', '26'], ['苯乙烯', 'byx_qh', '30']],
'shfe' : ['上海期货交易所', ['燃油', 'ry_qh', '13'], ['原油', 'yy_qh', '30'], ['沪铝', 'lv_qh', '1'], ['橡胶', 'xj_qh', '4'], ['沪锌', 'xing_qh', '17'],
['沪铜', 'tong_qh', '5'], ['黄金', 'hj_qh', '19', 'futures.fu_dig2'], ['螺纹钢', 'lwg_qh', '21'], ['线材', 'xc_qh', '22'],
['沪铅','qian_qh','25'],['白银','by_qh','25'],['沥青','lq_qh','25'],['热轧卷板','rzjb_qh','14'],['沪锡','xi_qh','21'],['沪镍','ni_qh','21'], ['纸浆','zj_qh','21'], ['20号胶','ehj_qh','21'], ['不锈钢','bxg_qh','21'], ['低硫燃料油','lu_qh','21'], ['国际铜','bc_qh','21']],
};
for i in ARRFUTURESNODES.values():
for test in i:
print(' '.join(test) if isinstance(test, list) else test)
|