N
N
nnikolyaa2020-08-23 12:43:28
Python
nnikolyaa, 2020-08-23 12:43:28

How to remove excess in split?

def set_chat_txt_setting(peid, number_text, text_chat):
    settings_massive=['text_hello','text_goodbye','text_kick']
    massnum=int(number_text-1)
    text_prosto_debag=text_chat
    print(str(text_prosto_debag))
    with sq.connect('users.db') as con:
        cur = con.cursor()
        print("Изменяется... "+str(settings_massive[massnum])+" "+str(number_text)+" "+str(text_chat))
        cur.execute("UPDATE chats SET "+str(settings_massive[massnum])+" = "+str(text_chat)+" WHERE chat_id="+str(peid)+"")
        con.commit()
        print("Изменено!")

I have such a record. As a result, text_chat is the following: The problem is that sqlite3 complains about [] and ''. The method with test pruning is no longer needed because at the beginning there is a variable whose value is specified by the user. Question: How to get rid of [] '' that everything is left with spaces?
['привет', 'лошок']

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-08-23
@nnikolyaa

need to use f-strings correctly

settings_massive=['text_hello','text_goodbye','text_kick']
massnum = 1
number_text = 5
text_chat = 777
print(f"Изменяется... {settings_massive[massnum]} {number_text} {text_chat}")
#Изменяется... text_goodbye 5 777

S
soremix, 2020-08-23
@SoreMix

' '.join(text_chat)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question