python - 如何从字符串中删除某些数据?
问题描述
此代码输出特定马匹的时间戳和赔率。我想从代码的输出中删除时间戳。
我的代码:
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]]
解决方案
以下
data = [[1598060018, 12.97], [1598060095, 13.13]]
new_data = [[x[1]] for x in data]
print(new_data)
输出
[[12.97], [13.13]]
推荐阅读
- image - 如何使用 OpenCV 查找图像上每个单独轮廓的高度和宽度
- rxjs - RxJs:您可以将运算符作为参数传播到管道运算符中吗
- html - 通过电子邮件发送 HTML 中的照片时出现问题
- javascript - fullcalendar timegridweek 不能正确显示事件时间
- video - 将 .mp4 批量转换为 hls 分段流
- driver - 如何从微型过滤器驱动程序中的 PUNICODESTRING 中提取 Volume 和 ParentDir?
- delphi - 较新的 Delphi 版本是否需要 FastStrings.pas?
- java - Heroku连接关闭而没有响应Java Spring-boot MySQL
- javascript - 静态文件使用 Angular 7 附加到表单数据中以发布 api http
- react-native - 如何在 React Native 中使用有限数量的数组中的数据使平面列表无限滚动