V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
AdamLee
V2EX  ›  Python

无法运行.pyw 文件

  •  
  •   AdamLee · 2019-03-14 21:03:44 +08:00 · 2629 次点击
    这是一个创建于 1841 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我可以通过 python test.py正常运行 python 文件,但是把该文件改为 test.pyw文件之后无法通过双击运行(也就是没有弹窗通知),这是咋回事,本人 python 新手,以下是示例代码:

    from win10toast import ToastNotifier
    
    toast = ToastNotifier()
    toast.show_toast('test title','test content')
    
    5 条回复    2019-03-15 23:09:51 +08:00
    v3aqb
        1
    v3aqb  
       2019-03-15 01:47:39 +08:00 via Android
    文件关联问题
    zhangjinglongi
        2
    zhangjinglongi  
       2019-03-15 09:15:37 +08:00
    pythonw.exe
    AdamLee
        3
    AdamLee  
    OP
       2019-03-15 09:36:55 +08:00
    @v3aqb 文件关联问题已经被我排除,因为我用其他代码做的.pyw 测试文件(代码内容只是生成一个.txt 文件然后写点东西)双击能够正常运行,但是我问题中的 toast 代码本来应该再 windows 中出现弹窗,但是双击这个文件之后一点反应都没有
    AdamLee
        4
    AdamLee  
    OP
       2019-03-15 09:38:31 +08:00
    @zhangjinglongi 其他测试用的.pyw 文件能正常双击运行,但是问题中的代码无法正常运行(本来应该再 windows 中出现通知弹窗)
    silkriver
        5
    silkriver  
       2019-03-15 23:09:51 +08:00
    可以先改回 test.py ,然后通过双击运行,就可以看控制台输出什么报错信息了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1587 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:57 · PVG 00:57 · LAX 09:57 · JFK 12:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.