简体   繁体   English

使用不同的参数值运行一个Python脚本

[英]Running a single Python script with different parameter values

I have a Python script called a.py , which takes 1 parameter from the command line. 我有一个名为a.py的Python脚本,该脚本a.py获取1个参数。 a.py is invoked as follows: python a.py 1 , where 1 is the parameter value. a.py的调用方式如下: python a.py 1 ,其中1是参数值。 Now, suppose I run a.py with 3 different parameter values on a single machine like this: 现在,假设我在单台机器上使用以下3个不同的参数值运行a.py

python a.py 1 &
python a.py 2 &
python a.py 3

I only see one a.pyc file. 我只看到一个a.pyc文件。 I wonder why there is only one a.pyc file since I invoke the program 3 times with 3 different parameters values, should there be 3 a.pyc files (maybe with different names)? 我想知道为什么只有一个a.pyc文件,因为我用3个不同的参数值调用了3次程序,是否应该有3个a.pyc文件(也许使用不同的名称)? If not, the a.pyc file couldn't contain all 3 parameters values, so where are the parameter values (ie, 1,2,3 ) stored? 如果不是,则a.pyc文件不能包含所有3个参数值,那么参数值(即1,2,3 )存储在哪里?

please refer this Difference py and pyc 请参考这个区别py和pyc

Basically parameters you are passing is just a system argument. 基本上,您要传递的参数只是一个系统参数。 When Py file is get compiled it converted into Byte Code, Where System argument is just a input parameter from command line so there will be single Pyc file for the same code base. 当编译Py文件时,它将转换为字节码,其中System参数只是命令行中的输入参数,因此对于相同的代码库,将只有一个Pyc文件。

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

相关问题 运行python脚本的不同方式 - different ways of running python script 将值发送到 python 脚本然后运行 - Sending values to python script then running 从 python 中的单个脚本运行多个脚本 - Running multiple scripts from a single Script in python 如何使用用于从Java执行python脚本的Process调用将StringBuilder中的不同值作为单独的参数传递 - How to pass different values in a StringBuilder as separate parameter with a Process call for executing python script from Java 使用批处理脚本运行具有不同路径的两个不同python脚本 - Running two different python script with different path using batch script 使用不同的参数多次运行 python 脚本 - Running python script several times with different parameters Python-属性错误(在其他PC上运行脚本) - Python - attribute error (running script on different PC) 从其他计算机运行python脚本 - Running a python script from different computers 为什么 `x = 1234`、`y = 1234`、`x is y` 在 REPL 中返回 False,但在独立脚本中返回 True? - Why does `x = 1234`, `y = 1234`, `x is y` return False in the REPL, but True in a stand-alone script? 从一个脚本运行多个Monkey Runner(Python脚本)程序 - Running Multiple Monkey Runner (Python script)Program from a single script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM