Except In Python Doesn't Response If File Doesn't Exist -
i search similar file names & want upload them user.
my problem when want use try/except see files exists, if files exists, try & else blocks works correctly if file doesn't exists, doesn't show user text ... problem ?
search = str(args[0]) pattern = re.compile('.*%s.*\.pdf' %search, re.i) files in filter(pattern.search, os.listdir('.')): try: requested_file = open(files, 'rb') except ioerror: bot.sendchataction(chat_id, 'typing') bot.sendmessage(chat_id, "this file doesn't exists") else: bot.sendchataction(chat_id, 'typing') bot.sendmessage(chat_id, "the file needed : " + files) bot.sendchataction(chat_id, 'upload_document') bot.senddocument(chat_id, requested_file, files) requested_file.close()
Comments
Post a Comment