<legend id='fY40h'><style id='fY40h'><dir id='fY40h'><q id='fY40h'></q></dir></style></legend>
    <bdo id='fY40h'></bdo><ul id='fY40h'></ul>

<i id='fY40h'><tr id='fY40h'><dt id='fY40h'><q id='fY40h'><span id='fY40h'><b id='fY40h'><form id='fY40h'><ins id='fY40h'></ins><ul id='fY40h'></ul><sub id='fY40h'></sub></form><legend id='fY40h'></legend><bdo id='fY40h'><pre id='fY40h'><center id='fY40h'></center></pre></bdo></b><th id='fY40h'></th></span></q></dt></tr></i><div id='fY40h'><tfoot id='fY40h'></tfoot><dl id='fY40h'><fieldset id='fY40h'></fieldset></dl></div>

    1. <tfoot id='fY40h'></tfoot>
      1. <small id='fY40h'></small><noframes id='fY40h'>

        在 Python 中读写环境变量?

        时间:2023-07-06

          • <tfoot id='VfA9k'></tfoot>

            <small id='VfA9k'></small><noframes id='VfA9k'>

              <bdo id='VfA9k'></bdo><ul id='VfA9k'></ul>

                  <i id='VfA9k'><tr id='VfA9k'><dt id='VfA9k'><q id='VfA9k'><span id='VfA9k'><b id='VfA9k'><form id='VfA9k'><ins id='VfA9k'></ins><ul id='VfA9k'></ul><sub id='VfA9k'></sub></form><legend id='VfA9k'></legend><bdo id='VfA9k'><pre id='VfA9k'><center id='VfA9k'></center></pre></bdo></b><th id='VfA9k'></th></span></q></dt></tr></i><div id='VfA9k'><tfoot id='VfA9k'></tfoot><dl id='VfA9k'><fieldset id='VfA9k'></fieldset></dl></div>
                  <legend id='VfA9k'><style id='VfA9k'><dir id='VfA9k'><q id='VfA9k'></q></dir></style></legend>
                    <tbody id='VfA9k'></tbody>

                • 本文介绍了在 Python 中读写环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 python 脚本调用了许多 python 函数和 shell 脚本.我想在 Python(主调用函数)和所有子进程(包括 shell 脚本)中设置环境变量以查看环境变量集.

                  My python script which calls many python functions and shell scripts. I want to set a environment variable in Python (main calling function) and all the daughter processes including the shell scripts to see the environmental variable set.

                  我需要像这样设置一些环境变量:

                  I need to set some environmental variables like this:

                  DEBUSSY 1
                  FSDB 1
                  

                  1 是一个数字,而不是一个字符串.此外,如何读取存储在环境变量中的值?(就像另一个 python 子脚本中的 DEBUSSY/FSDB.)

                  1 is a number, not a string. Additionally, how can I read the value stored in an environment variable? (Like DEBUSSY/FSDB in another python child script.)

                  推荐答案

                  尝试使用 os 模块.

                  import os
                  
                  os.environ['DEBUSSY'] = '1'
                  os.environ['FSDB'] = '1'
                  
                  # Open child processes via os.system(), popen() or fork() and execv()
                  
                  someVariable = int(os.environ['DEBUSSY'])
                  

                  请参阅 os.environ<上的 Python 文档/代码>.此外,有关生成子进程的信息,请参阅 Python 的 子进程文档.

                  See the Python docs on os.environ. Also, for spawning child processes, see Python's subprocess docs.

                  这篇关于在 Python 中读写环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                      <tbody id='Aw62O'></tbody>
                      <bdo id='Aw62O'></bdo><ul id='Aw62O'></ul>

                    • <tfoot id='Aw62O'></tfoot>

                      <legend id='Aw62O'><style id='Aw62O'><dir id='Aw62O'><q id='Aw62O'></q></dir></style></legend>

                    • <i id='Aw62O'><tr id='Aw62O'><dt id='Aw62O'><q id='Aw62O'><span id='Aw62O'><b id='Aw62O'><form id='Aw62O'><ins id='Aw62O'></ins><ul id='Aw62O'></ul><sub id='Aw62O'></sub></form><legend id='Aw62O'></legend><bdo id='Aw62O'><pre id='Aw62O'><center id='Aw62O'></center></pre></bdo></b><th id='Aw62O'></th></span></q></dt></tr></i><div id='Aw62O'><tfoot id='Aw62O'></tfoot><dl id='Aw62O'><fieldset id='Aw62O'></fieldset></dl></div>
                      • <small id='Aw62O'></small><noframes id='Aw62O'>