我搜索相似的文件名并希望为用户上传它们。你知道吗
我的问题是,当我想使用Try/Except查看此文件是否存在时,如果文件存在,Try&Else块会正常工作,但如果文件不存在,它不会向用户显示文本。。。有什么问题?你知道吗
search = str(args[0])
pattern = re.compile('.*%s.*\.pdf' %search, re.I)
for 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 You Needed : " + files)
bot.sendChatAction(chat_id, 'upload_document')
bot.sendDocument(chat_id, requested_file, files)
requested_file.close()
目前没有回答
相关问题 更多 >
编程相关推荐