sys.argv [1]在脚本中的含义(sys.argv[1] meaning in script)
我目前正在教自己的Python,只是简单地想想sys.argv [1]代表什么(参考我的例子)。 它只是要求输入吗?
#!/usr/bin/python3.1 # import modules used here -- sys is a very standard one import sys # Gather our code in a main() function def main(): print ('Hello there', sys.argv[1]) # Command line args are in sys.argv[1], sys.argv[2] .. # sys.argv[0] is the script name itself and can be ignored # Standard boilerplate to call the main() function to begin # the program. if __name__ == '__main__': main()
I'm currently teaching myself Python and was just wondering (In reference to my example below) in simplified terms what the
sys.argv[1]
represents. Is it simply asking for an input?#!/usr/bin/python3.1 # import modules used here -- sys is a very standard one import sys # Gather our code in a main() function def main(): print ('Hello there', sys.argv[1]) # Command line args are in sys.argv[1], sys.argv[2] .. # sys.argv[0] is the script name itself and can be ignored # Standard boilerplate to call the main() function to begin # the program. if __name__ == '__main__': main()
原文:https://stackoverflow.com/questions/4117530
更新时间:2023-06-07 21:06
最满意答案
用Chrome,IE和Firefox测试:
<iframe id="remember" name="remember" class="hidden" src="/content/blank"></iframe> <form target="remember" method="post" action="/content/blank"> <fieldset> <label for="username">Username</label> <input type="text" name="username" id="username" value=""> <label for="password">Password</label> <input type="password" name="password" id="password" value=""> </fieldset> <button type="submit" class="hidden"></button> </form>
在您的Javascript触发器中提交,例如
$("form").submit();
$("#submit_button").click()
(从评论更新)您需要在/ content / blank中返回一个空页面以获取和发布(关于:空白不适用于我,但是YMMV)。
Tested with Chrome, IE and Firefox:
<iframe id="remember" name="remember" class="hidden" src="/content/blank"></iframe> <form target="remember" method="post" action="/content/blank"> <fieldset> <label for="username">Username</label> <input type="text" name="username" id="username" value=""> <label for="password">Password</label> <input type="password" name="password" id="password" value=""> </fieldset> <button type="submit" class="hidden"></button> </form>
In your Javascript trigger the submit, e.g.
$("form").submit();
$("#submit_button").click()
(updated from comments)You need to return an empty page at /content/blank for get & post (about:blank didn't work for me but YMMV).
相关问答
更多-
让它在禁用之前进行提交: $("#uploadForm").submit(function () { setTimeout(function(){$("#uploadForm :input").attr('disabled','disabled');}, 10); return true; }); Let it do the submit before disabling: $("#uploadForm").submit(function () { setTimeout(funct ...
-
用Chrome,IE和Firefox测试: