python小白一枚,今天下载了个项目,但是运行的时候显示缺少参数,不太理解缺少什么参数,应该怎么运行

Homo Sapiens Deepensis 2020-06-23 04:05:38

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里运行时,出现了如下情况


本小白目前还在入门学习阶段,对于出现的这个问题,不是很了解 ,求大神指导
...全文
206 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
青柍 2020-06-30
  • 打赏
  • 举报
回复
这个是你文件的前面的if,elif都没有符合条件,没有运行,运行的是最后的else,打印的最后一行内容,也不属于报错
  • 打赏
  • 举报
回复
或者说,我该如何操作,才能正常运行这个py文件呢,想听下原理

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧