简体   繁体   English

接受Python中的文件参数(从发送到上下文菜单)

[英]Accepting File Argument in Python (from Send To context menu)

I'm going to start of by noting that I have next to no python experience. 我将首先注意到我没有python经验。

alt text http://www.aquate.us/u/9986423875612301299.jpg alt text http://www.aquate.us/u/9986423875612301299.jpg

As you may know, by simply dropping a shortcut in the Send To folder on your Windows PC, you can allow a program to take a file as an argument. 您可能知道,只需在Windows PC上的“发送到”文件夹中删除快捷方式,就可以允许程序将文件作为参数。

How would I write a python program that takes this file as an argument? 我如何编写一个以此文件为参数的python程序?

And, as a bonus if anyone gets a chance -- How would I integrate that with a urllib2 to POST the file to a PHP script on my server? 并且,如果有人有机会作为奖励 - 我如何将其与urllib2集成以将文件POST到我的服务器上的PHP脚本?

Thanks in advance. 提前致谢。

Edit-- also, how do I make something show up in the Sendto menu? 编辑 - 另外,如何在Sendto菜单中显示某些内容? I was under the impression that you just drop a shortcut into the SendTo folder and it automatically adds an option in the menu... Never mind. 我的印象是你只是将一个快捷方式放入SendTo文件夹,它会自动在菜单中添加一个选项......没关系。 I figured out what I was doing wrong :) 我弄清楚我做错了什么:)

import sys

for arg in sys.argv:
  print arg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM