P
P
pivazik2020-06-04 00:00:38
Python
pivazik, 2020-06-04 00:00:38

How to remove quotes from a list in Python?

Hello, there was a problem when writing numbers to a sheet, you need them to be written without quotes ["123456789", "123456789"], i.e. like this - [123456789, 123456789]
Here is the script itself:

if msg[0:4] == "%бан":
      get_user = re.search("\d{1,}", msg)
      user_id = event.obj["from_id"]
      if user_id in creator:
        if get_user[0] not in ban_list:
          ban_list.append(get_user[0])
          print(ban_list)
          with open('ban_list.txt', 'w') as filehandle:
            json.dump(ban_list, filehandle)

After the ID is written to a list and a JSON file with quotes:
5ed80f667f464742511927.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MechanicZelenyy, 2020-06-04
@pivazik

ban_list.append(int(get_user[0]))

A
Anastasia Taube, 2020-06-04
@Tayaki

Hope it helps. :)
The third link on request in Google:

You can join words into one line using join with a space as a separator, and then output:
words = ['end', 'nend']
print(' '.join(words))

Another option, if just words need to be output, then you can pass a list of words to print through an asterisk, then each word will be passed to print as a separate parameter:
words = ['end', 'nend']
print(*words)

To display the same words on several lines, in the first variant we simply change the separator to '\n':
words = ['end', 'nend']
print('\n'.join(words))

In the second option, you still need to explicitly set the separator:
words = ['end', 'nend']
print(*words, sep='\n')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question