我想使用for循环在列表中打印列表,我正在做的是:
k = "/BTC"
for i in range(l):
if k in dat1["Data"][i]['Label']:
value = dat1["Data"][i]['Label']
value1 = dat1["Data"][i]['TradePairId']
value2 = dat1["Data"][i]['AskPrice']
value3 = dat1["Data"][i]['BidPrice']
li1 = [value, value1, value2, value3]
list = [li1+1 for g in li1]
print(float(list))
每次迭代' li1'有一些值,我想创建一个新的列表,应该存储' li1'进入每次迭代的索引,然后最后打印整个列表。提前致谢
答案 0 :(得分:0)
不确定您的意思"存储' li1'的数据进入索引"。我假设你想要一份清单清单?你可以附上清单。
k = "/BTC"
result_list = []
for i in range(l):
if k in dat1["Data"][i]['Label']:
value = dat1["Data"][i]['Label']
value1 = dat1["Data"][i]['TradePairId']
value2 = dat1["Data"][i]['AskPrice']
value3 = dat1["Data"][i]['BidPrice']
result_list.append([value, value1, value2, value3])
print(result_list)