How can python import all the variables in the text and extract the variable values? -PHP Chinese website Q&A-Python How to import all the variables in the text and extract the variable values? -PHP Chinese website Q&A
fp = open("/etc/sf.cfg")
lines = fp.readlines()
fp.close()
for line in lines:
items = line.split("=")
key = items[0].strip()
value = items[1].strip()
os.environ[key] = value
How can python import all the variables in the text and extract the variable values? -PHP Chinese website Q&A-Python How to import all the variables in the text and extract the variable values? -PHP Chinese website Q&A
Let’s take a look and learn.
楼主方法不对.os.system是创建子进程的.所以结果是不会返回到父进程的.
设置环境变量可以如下: