import os
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Wechat helper(微信小助手), Author: Charles, WeChat Official Accounts: Charles_pikachu(微信公眾號: Charles的皮卡丘), Version: V0.1.0")
parser.add_argument('-o', dest='option', help='Choose the function you need, including <analysisFriends>, <antiWithdrawal>, <wechatRobot> and <autoReply>.\
(選擇你需要的功能, 可選項包括: 好友分析<analysisFriends>, 訊息防撤回<antiWithdrawal>, 開啟自動聊天機器人<wechatRobot> 和 微信訊息自動回復<autoReply>)')
parser.add_argument('-k', dest='keywords', help='Keywords for <autoReply>, use "*" to separate if keywords is more than one.(選擇autoRelpy功能時的關鍵詞, 若有多個關鍵詞則用*分隔)')
parser.add_argument('-c', dest='contents', help='Contents for <autoReply>, use "*" to separate if contents is more than one.(選擇autoRelpy功能時的回復內容, 若有多個回復內容則用*分隔)')
args = parser.parse_args()
if args.option == 'analysisFriends':
from utils.analysisFriends import analysisFriends
print('[INFO]: analysisFriends...')
savedir = os.path.join(os.getcwd(), 'results')
analysisFriends().run(savedir=savedir)
print('[INFO]: analysis friends successfully, results saved into %s...(微信好友分析成功, 結果保存在%s...)' % (savedir, savedir))
elif args.option == 'antiWithdrawal':
from utils.antiWithdrawal import antiWithdrawal
print('[INFO]: antiWithdrawal...')
antiWithdrawal().run()
elif args.option == 'wechatRobot':
from utils.wechatRobot import wechatRobot
print('[INFO]: wechatRobot...')
wechatRobot().run()
elif args.option == 'autoReply':
from utils.autoReply import autoReply
print('[INFO]: autoReply...')
keywords = args.keywords
contents = args.contents
if keywords:
keywords = keywords.split('*')
if contents:
contents = contents.split('*')
autoReply().run(keywords=keywords, replycontents=contents)
else:
print('[INFO]: argparse error...(引數決議出錯, 可選項必須是<analysisFriends>, <antiWithdrawal>, <wechatRobot> 或 <autoReply>)')
當我把這個py檔案放在VSCode里運行時,出現了如下情況

本小白目前還在入門學習階段,對于出現的這個問題,不是很了解 ,求大神指導
uj5u.com熱心網友回復:
或者說,我該如何操作,才能正常運行這個py檔案呢,想聽下原理uj5u.com熱心網友回復:
這個是你檔案的前面的if,elif都沒有符合條件,沒有運行,運行的是最后的else,列印的最后一行內容,也不屬于報錯轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/29982.html
