Skip to content

Instantly share code, notes, and snippets.

@DGideas
Created March 8, 2021 16:15
Show Gist options
  • Select an option

  • Save DGideas/c6ba07e7be68b00c24ac5751be37da16 to your computer and use it in GitHub Desktop.

Select an option

Save DGideas/c6ba07e7be68b00c24ac5751be37da16 to your computer and use it in GitHub Desktop.
a = [
{"userid":"Change","tags":[{"type":1,"tag_id":"e" }],},
{"userid":"andy.lei","tags":[{"type":1,"tag_id":"eg" },{"type":1,"tag_id":"ti"}],}
]
result = []
[*map(lambda x: result.extend([{"userid": x["userid"], "tagid": tag["tag_id"]} for tag in x["tags"]]), a)]
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment