0
I’m trying to read a file . txt (currently empty) to check if chat_id already exists, if it already exists, it ends right there. If it doesn’t exist... Add the new chat_id in the last line, but when I run the code and see the file, there is nothing written on it and there is no error in the terminal... Where am I going wrong?
def add_chat(self):
#print(self.msg_chat_id) output: -10052348214
with open('bot_chat_ids.txt', 'r') as allchats:
for chat in allchats:
if str(self.msg_chat_id) == chat:
return
with open('bot_chat_ids.txt', 'a') as allchats:
allchats.write(str(self.msg_chat_id) + '\n')
Can you explain better the part of re.sub()? It is a module re?
– dfop02
ah yes, I will comment on the reply
– AnthraxisBR