术语:Argv,调用程序 [英] Terminology: Argv, Invoking a program

查看:24
本文介绍了术语:Argv,调用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hy Python 社区 -

Hy Python Community -

这是一个关于 Argv 和调用"的基本术语问题

This is a basic terminology question about Argv and "invoke"

我是 Python 和编程的新手.

I'm new to python and programmring.

我正在阅读 openbookproject.com 上 sys 模块中的 argv 函数:

I was reading about the argv function in the sys module on openbookproject.com:

argv 变量保存 Python 脚本运行时从命令行读入的字符串列表.这些命令行参数可用于将信息传递给程序在调用程序的同时强>."http://openbookproject.net/thinkcs/python/english2e/ch10.html

"The argv variable holds a list of strings read in from the command line when a Python script is run. These command line arguments can be used to pass information into a program at the same time it is invoked." http://openbookproject.net/thinkcs/python/english2e/ch10.html

从定义来看似乎很清楚,但我仍然想仔细检查:在调用时"是否只是意味着当您运行程序时?"以第三种方式说Argv 可以在运行时将信息传递到程序中"是否合适?

It seems really clear from the defintion, but I still wanted to double check: Does "at the time it is invoked" just mean, "when you run the program?" Would it be appropriate in a third way to say, "Argv can pass information into a program at runtime?"

谢谢.

推荐答案

在它被调用时"是否只是意味着当你运行程序时?"

Does "at the time it is invoked" just mean, "when you run the program?"

是的.同时被调用"意味着您可以稍后在程序运行时将数据传递给程序,即,您可以使用命令行参数(sys.argv) 将数据传递给程序同时它被调用" 和一些其他方式(IPC) 稍后通过,例如,在运行时通过标准输入.

Yes. "at the same time it is invoked" implies that you can pass data to the program later while it is running too i.e., you can use command-line arguments (sys.argv) to pass data to the program "at the same time it is invoked" and some other means (IPC) to pass it later e.g., via standard input while it is running.

第三种说法是否合适,Argv 可以在运行时将信息传递给程序?"

Would it be appropriate in a third way to say, "Argv can pass information into a program at runtime?"

没有

argv 定义了命令行在进程中的样子,例如,argv[0] 为进程设置一个名称(另一个来自实际可执行文件的路径).在 POSIX 上,argv 的参数exec*() 函数 传递给 C main(argc, argv) 这是 C 程序的入口点.

argv defines how the command line looks like to the process e.g., argv[0] sets one of the name for the process (another one is derived from the path to the actual executable). On POSIX, argv is a parameter for exec*() functions that is passed to C main(argc, argv) that is the entry point for a C program.

换句话说,argv 用于调用(启动/运行)进程,但作为 @GFetterman 提到在运行时"可能是指整个进程的运行时间,而不仅仅是调用时间.argv 甚至可能在进程运行之前就已经知道,并且 argv 通常在进程启动后保持不变.

In other words, argv is used to invoke (start/run) the process but as @G Fetterman mentioned "at runtime" may refer to the whole process running time, not only the invocation time. argv may be known even before the process is running and argv usually stays the same after the process is started.

这篇关于术语:Argv,调用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆