Windows “open with” python py2exe application

…衆ロ難τιáo~ 提交于 2019-12-12 03:56:49

问题


I wonder how the Windows "Open file with..." feature works. Or rather, how would do if I write a program in python, compile a executable with py2exe and then want to be able to open certain files in that program by right-clicking and choose it in "Open with".

Is the file simply passed as an argument, like "CMD>C:/myapp.exe file"?


回答1:


Yep, the path to the file gets passed in as an argument and can be accessed via sys.argv[1].




回答2:


You can use more functionally argparse module



来源:https://stackoverflow.com/questions/15393202/windows-open-with-python-py2exe-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!