M
M
Maxim Yumikov2021-11-05 22:41:36
Python
Maxim Yumikov, 2021-11-05 22:41:36

How to display all the data from for in and then add it to the database?

Faced a problem after a long break in the study. I want to display this (a little lower) in normal text, so that through for in everything is in one line to be added to the database
. An example will be through the BrawlStats api library

import brawlstats

cl = brawlstats.Client(тут токен)
player = cl.get_profile("#9VU9R2LY")#взял случайный рабочий тэг
clubinfo = cl.get_club(str(player.club.tag))
clubmembers = clubinfo.members
print(clubmembers)

After output through print, the result will be approximately like this
[{'tag': '#9VU9R2LY', 'name': '@TERI_BS', 'name_color': '0xffffffff', 'role': 'president', 'trophies': 57726, 'icon': {'id' : 28000044}}, {'tag': '#2PY2R9YQ', 'name': '3BS_youtubeQQQ⛥', 'name_color': '0xffffffff', 'role': 'member', 'trophies': 49081, 'icon': {'id': 28000054}}, {'tag': '#2LJ820QR', 'name': 'NE|HYUN', 'name_color': '0xffff9727', 'role': 'member', 'trophies': 48467 , 'icon': {'id': 28000061}}, {'tag': '#89R29VUU8', 'name': 'ほーぷ', 'name_color': '0xfff9c908', 'role': 'member', 'trophies': 46918, 'icon': {'id': 28000071}}

for names in clubmembers:
  print(names["name"])

It will output something like this:

@TERI_BS
3BS_youtubeQQQ⛥
NE|HYUN
ほーぷ
♚MUB❦(存)♚
Sakura | さくら
‍♂️魔法のらむくん❦
5月|Tobi

If I try to add this to the database, it will only write the first value, but I need it to look like this in the database: was in one post)

@TERI_BS
3BS_youtubeQQQ⛥
NE|HYUN
ほーぷ
♚MUB❦(存)♚
Sakura | さくら
‍♂️魔法のらむくん❦
5月|Tobi

I'm not very good at explaining this, so I'll answer questions in the comments

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question