此代碼輸出特定馬匹的時間戳和賠率。我想從代碼的輸出中刪除時間戳。我的代碼:request2 = requests.get('https://www.punters.com.au/api/web/public/Odds/getOddsComparisonCacheable/?allowGet=true&APIKey=65d5a3e79fcd603b3845f0dc7c2437f0&eventId=1045618&betType=FixedWin', headers={'User-Agent': 'Mozilla/5.0'})json2 = request2.json()for selection in json2['selections']: for fluc in selection['flucs'][0]: data = ast.literal_eval(selection['flucs']) print(data[-2:])代碼輸出:[[1598060018, 12.97], [1598060095, 13.13]][[1598060066, 4.41], [1598060095, 4.36]][[1598060030, 2.11], [1598060095, 2.12]][[1598060030, 5.69], [1598060095, 5.61]][[1598059986, 16.35], [1598060095, 16.6]][[1598060006, 12.06], [1598060095, 12.35]][[1598060026, 25.83], [1598060095, 26.25]][[1598060026, 39.25], [1598060095, 39.83]]代碼的期望輸出:[[12.97], [13.13]][[4.41], [4.36]][[2.11], [2.12]]
2 回答

慕碼人2483693
TA貢獻1860條經驗 獲得超9個贊
以下
data = [[1598060018, 12.97], [1598060095, 13.13]]
new_data = [[x[1]] for x in data]
print(new_data)
輸出
[[12.97], [13.13]]

MYYA
TA貢獻1868條經驗 獲得超4個贊
for lsst in new data:
a=[str(item) for item in lsst if "." not in lsst]
或者
if type==float:
"keep it"
else:
"remove .. delete whatever"
添加回答
舉報
0/150
提交
取消