简体   繁体   English

Python 使用环境变量

[英]Python using environment variables

I'm new to programming, and right now I'm working in a small personal project that uses environment variables to create global variables through classes, files, threads, and flask pages in a extremely easier way.我是编程新手,现在我在一个小型个人项目中工作,该项目使用环境变量以极其简单的方式通过类、文件、线程和 flask 页面创建全局变量。

But I do have some questions about how it will work on mine and other computers.但我确实有一些关于它将如何在我的和其他计算机上工作的问题。

  1. Do the " os.environ " and " os.getenv " work equally in all systems (windows, mac and linux)? os.environ ”和“ os.getenv ”在所有系统(windows、mac 和 linux)中是否同样有效?
  2. How about the character limit?字数限制怎么样? I'm using a single variable to keep a json dictionary, so how much info can I put in there?我使用单个变量来保存json字典,那么我可以在那里输入多少信息?
  3. Is there a way to block the access to the environment variables?有没有办法阻止对环境变量的访问? Is it normal in companies and universities to block the access to them?公司和大学阻止访问它们是否正常?
  1. yes they work same, nothing different is mentioned in official documentation.是的,它们的工作原理相同,官方文档中没有提到任何不同。
  2. char limit depends on your system specification.字符限制取决于您的系统规格。 please refer: What is the max length of a python string?请参考: python 字符串的最大长度是多少?
  3. to block the access to the env var you can use "deny" eg.要阻止对环境变量的访问,您可以使用“拒绝”,例如。
    Deny from env="users"

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM