Answer the question
In order to leave comments, you need to log in
Why does zipfile.is_zipfile(filename) return False?
Hello everyone, I've run into this problem.
There is a bot to which I send a ZIP archive, it saves it on my computer, and then it has to unpack it into another folder, and then there are other actions ...
If you just do it through a .py script:
import zipfile
zf = zipfile.is_zipfile('test.zip')
print(zf)
if zipfile.is_zipfile('test.zip'):
bot.send_message(chat_id, "It's a ZIP file")
else:
bot.send_message(chat_id, "WRONG FILE!!!")
Answer the question
In order to leave comments, you need to log in
Received the file like this
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
src = 'path' + message.document.file_name;
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
new_file.close()
After which everything works like a clock.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question