如何从2d列表中提取满足某些条件的值列表?
如何清除空列表和多余的括号?
## application.yml
---
spring:
profiles: dev
datasource:
platform: postgres
url:
jdbc:postgresql://${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}
username: ${DATABASE_USER}
password: ${DATABASE_PASSWORD}
driverClassName: org.postgresql.Driver
initialize: true
liquibase:
change-log: classpath:db/changelog-master.xml
答案 0 :(得分:0)
使用列表理解:
grid = [[10,13,17],[3,5,1],[13,1,12]]
results = [(i, b) for b in range(len(grid)) for i, a in enumerate(grid[b]) if a == 1]
输出:
[(2, 1), (1, 2)]