在Python应用程序之间保存参数 [英] Saving parameters between Python applications?

查看:79
本文介绍了在Python应用程序之间保存参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做以下事情。我有一个Python应用程序

运行:


python app1.py --location = c:\ test1


我想要做的是保存位置参数,这样我就可以(在

的同一个窗口中):


python app2。 py


让app2.py自动访问location的值。


现在,困难的部分是,那个在另一个窗口我想做:


python app1.py --location = c:\ test2

python app2.py


并让app2.py自动获取c:\ test2作为位置。所以

两个窗口(控制台)彼此隔离。


我以为我可以使用os.environ,但这并不能保存变量

用于在同一窗口中运行的应用程序。


有什么建议吗?


谢谢

I''m trying to do the following. I have a Python application that is
run:

python app1.py --location=c:\test1

What I want to do is save the location parameter, so I can then do (in
the same window):

python app2.py

And have app2.py automatically have access to the value of "location".

Now, the difficult part is, that in another window I want to do:

python app1.py --location=c:\test2
python app2.py

And have app2.py automatically get c:\test2 as the location. So the
two windows (consoles) are isolated from each other.

I thought I could use os.environ, but that doesn''t save the variable
for applications that are run afterwards in the same window.

Any suggestions?

Thanks

推荐答案

2007年9月16日,Stodge< st **** @ gmail.comwrote:
On 9/16/07, Stodge <st****@gmail.comwrote:

python app1.py --location = c:\ test1

我想要做的是保存位置参数,这样我就可以了(在

同一个窗口):

python app2.py

让app2.py自动访问location的值。
python app1.py --location=c:\test1
What I want to do is save the location parameter, so I can then do (in
the same window):
python app2.py
And have app2.py automatically have access to the value of "location".



使用app1.py保存你希望app2阅读的价值的泡菜。


-

Sebasti ?? n Bassi(????????????????????????? Diplomado en Ciencia y Tecnolog?* a。

Curso Biologia molecular para programadores: http ://tinyurl.com/2vv8w6

GPG指纹:9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D

Do app1.py to save a pickle of the value you want app2 to read.

--
Sebasti??n Bassi (????????1?????£??¢??3). Diplomado en Ciencia y Tecnolog?*a.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D


好主意,但我不能保证这两个脚本将从

运行到同一目录 - 那么在哪里存储泡菜?


9月16日,下午5:25,Sebastian Bassi < sba ... @ clubdelarazon.org>

写道:
Good idea, but I can''t guarantee that the two scripts will be run from
the same directory - so where to store the pickle?

On Sep 16, 5:25 pm, "Sebastian Bassi" <sba...@clubdelarazon.org>
wrote:

2007年9月16日,Stodge< sto .. 。@ gmail.comwrote:
On 9/16/07, Stodge <sto...@gmail.comwrote:

python app1.py --location = c:\ test1

我想做的就是保存location参数,所以我可以这样做(在

同一个窗口):

python app2.py

自动拥有app2.py可以访问location的值。
python app1.py --location=c:\test1
What I want to do is save the location parameter, so I can then do (in
the same window):
python app2.py
And have app2.py automatically have access to the value of "location".



使用app1.py来保存你希望app2阅读的价值的泡菜。


-
$ b $bSebastiánBassi()。 Diplomado en CienciayTecnología。

Curso Biologia molecular para programadores: http:// tinyurl.com/2vv8w6

GPG指纹:9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D


Do app1.py to save a pickle of the value you want app2 to read.

--
Sebastián Bassi ( ). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores:http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D


开9/17/07,Stodge< st **** @ gmail.comwrote:
On 9/17/07, Stodge <st****@gmail.comwrote:

好​​主意,但我不能保证这两个脚本会从

运行同一目录 - 那么存储pickle的位置?
Good idea, but I can''t guarantee that the two scripts will be run from
the same directory - so where to store the pickle?



只要两个

程序都可以访问pickle文件,是否是同一目录并不重要(一个程序应该写入

访问权限,另一个程序应该至少具有读取权限。)


-

Sebasti? ?Bassi(????????????????????? Diplomado en Ciencia y Tecnolog?* a。

Curso Biologia molecular para programadores: http ://tinyurl.com/2vv8w6

GPG指纹:9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D

It doesn''t matter if is the same directory or not, as long as both
programs has access to the pickle file (one program should have write
access and the other program should have at least read access).

--
Sebasti??n Bassi (????????1?????£??¢??3). Diplomado en Ciencia y Tecnolog?*a.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D


这篇关于在Python应用程序之间保存参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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