<legend id='H85AR'><style id='H85AR'><dir id='H85AR'><q id='H85AR'></q></dir></style></legend>
    <tfoot id='H85AR'></tfoot>
    1. <i id='H85AR'><tr id='H85AR'><dt id='H85AR'><q id='H85AR'><span id='H85AR'><b id='H85AR'><form id='H85AR'><ins id='H85AR'></ins><ul id='H85AR'></ul><sub id='H85AR'></sub></form><legend id='H85AR'></legend><bdo id='H85AR'><pre id='H85AR'><center id='H85AR'></center></pre></bdo></b><th id='H85AR'></th></span></q></dt></tr></i><div id='H85AR'><tfoot id='H85AR'></tfoot><dl id='H85AR'><fieldset id='H85AR'></fieldset></dl></div>
      • <bdo id='H85AR'></bdo><ul id='H85AR'></ul>

    2. <small id='H85AR'></small><noframes id='H85AR'>

      Python脚本不适用于双击

      Python script doesn#39;t work with double click(Python脚本不适用于双击)

          <tbody id='kdrLJ'></tbody>

        <legend id='kdrLJ'><style id='kdrLJ'><dir id='kdrLJ'><q id='kdrLJ'></q></dir></style></legend>

          <bdo id='kdrLJ'></bdo><ul id='kdrLJ'></ul>

            <small id='kdrLJ'></small><noframes id='kdrLJ'>

              <i id='kdrLJ'><tr id='kdrLJ'><dt id='kdrLJ'><q id='kdrLJ'><span id='kdrLJ'><b id='kdrLJ'><form id='kdrLJ'><ins id='kdrLJ'></ins><ul id='kdrLJ'></ul><sub id='kdrLJ'></sub></form><legend id='kdrLJ'></legend><bdo id='kdrLJ'><pre id='kdrLJ'><center id='kdrLJ'></center></pre></bdo></b><th id='kdrLJ'></th></span></q></dt></tr></i><div id='kdrLJ'><tfoot id='kdrLJ'></tfoot><dl id='kdrLJ'><fieldset id='kdrLJ'></fieldset></dl></div>
              <tfoot id='kdrLJ'></tfoot>
              • 本文介绍了Python脚本不适用于双击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个非常基本的问题,但我无法在旧答案中找到解决方案.当我双击 python 脚本时,我可以看到一个提示闪烁,但没有任何反应.如果我用 IDLE 打开相同的脚本并运行它,一切正常.为了确保脚本没有正确执行,我制作了一个这样的测试脚本:

                I have a very basic problem, but I cannot find a solution in older answers. When I double click on a python script, I can see a prompt flashing but nothing happens. If I open the same script with IDLE and run it, everything works fine. To be sure the script was not executing propoerly, I made a test script like this:

                def main():
                   files = open('test.txt','a')
                   files.write('this is a test')
                

                如果通过空闲启动,简单脚本会写入文件,但如果我双击它,则不会发生任何事情.我尝试使用 .py 和 pyw 扩展名以及不止一台(Windows)电脑.我将python文件夹添加到路径中无济于事.

                The simple script write the file if launched thru idle, but nothing happens if if I double click it. I tried with both .py and pyw extension and in more than one (windows) pc. I added the python folder to the path with no avail.

                谢谢!

                推荐答案

                确保脚本包含这段代码:

                Make sure that the script includes this snippet of code:

                if __name__ == "__main__":
                    # call your code here
                    main()
                

                这是从命令行运行的脚本的执行入口点,例如 C/C++/Java/C# 中的 main() 函数.在 this 帖子中了解更多信息.

                That's the execution entry point for a script running from the command line, like the main() function in C/C++/Java/C#. Read more about it in this post.

                另外,不要忘记显而易见的 - 为脚本提供正确的执行权限,确保 python.exe 命令在 %PATH% 中可用环境变量等.

                Also, don't forget the obvious - give the right execution permissions to the script, make sure that the python.exe command is available in the %PATH% environment variable, and so on.

                这篇关于Python脚本不适用于双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)

                <legend id='wCJQ8'><style id='wCJQ8'><dir id='wCJQ8'><q id='wCJQ8'></q></dir></style></legend>

                1. <i id='wCJQ8'><tr id='wCJQ8'><dt id='wCJQ8'><q id='wCJQ8'><span id='wCJQ8'><b id='wCJQ8'><form id='wCJQ8'><ins id='wCJQ8'></ins><ul id='wCJQ8'></ul><sub id='wCJQ8'></sub></form><legend id='wCJQ8'></legend><bdo id='wCJQ8'><pre id='wCJQ8'><center id='wCJQ8'></center></pre></bdo></b><th id='wCJQ8'></th></span></q></dt></tr></i><div id='wCJQ8'><tfoot id='wCJQ8'></tfoot><dl id='wCJQ8'><fieldset id='wCJQ8'></fieldset></dl></div>
                    <bdo id='wCJQ8'></bdo><ul id='wCJQ8'></ul>

                        1. <tfoot id='wCJQ8'></tfoot>
                        2. <small id='wCJQ8'></small><noframes id='wCJQ8'>

                            <tbody id='wCJQ8'></tbody>