栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何从命令行调试使用python -m运行的Python模块?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何从命令行调试使用python -m运行的Python模块?

您现在无法执行此操作,因为会

-m
终止选项列表

python -h...-m mod : run library module as a script (terminates option list)...

这意味着 mod的 工作是解释其余的参数列表,而这种行为完全取决于 mod 在内部的设计方式以及它是否支持另一个 -m

让我们看看里面有什么发生PDB的
蟒蛇2.x的 。实际上,没有什么可解释的,它只希望提供一个脚本名称:

   if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):        print "usage: pdb.py scriptfile [arg] ..."        sys.exit(2)    mainpyfile =  sys.argv[1]     # Get script filename    if not os.path.exists(mainpyfile):        print 'Error:', mainpyfile, 'does not exist'        sys.exit(1)    del sys.argv[0]         # Hide "pdb.py" from argument list    # Replace pdb's dir with script's dir in front of module search path.    sys.path[0] = os.path.dirname(mainpyfile)    # Note on saving/restoring sys.argv: it's a good idea when sys.argv was    # modified by the script being debugged. It's a bad idea when it was    # changed by the user from the command line. There is a "restart" command    # which allows explicit specification of command line arguments.    pdb = Pdb()    while True:        try: pdb._runscript(mainpyfile)

与当前发布的 python
3.x
版本相同

好消息

5天前,已合并了可以执行您要问的请求请求。多么神秘的巧合!这是代码

因此,请稍等一下即将发布的python 3.x版本,以解决此问题)



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/640362.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号