开发者

Python: open a file *with* script?

I have a python script bundled into a application (I'm on a mac) and have the application set to be able to open .zip files. But when I say "open foo.zip with bar.py" h开发者_高级运维ow do I access the file that I have passed to it?

Additional info: Using tkinter.

What's a good way to debug this, as there is no terminal to pass info to?


You should be using sys.argv[1]

task = sys.argv[1].decode('utf-8')
if task == u'uppercase':
    pass
elif task == u'openitems':
    item_paths = sys.argv[2:]
    for itempath in item_paths:
        itempath = itempath.decode('utf-8')


If I'm not greatly mistaken, it should pass the name of the file as the first argument to the script - sys.argv[1].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜