简体   繁体   English

os.getenv(“username”) 不返回环境变量而是我的名字

[英]os.getenv(“username”) not returning environment variable instead my name

So I was using a API and had to give my account username and password.所以我使用的是 API 并且必须提供我的帐户用户名和密码。 I kept getting a authentication error, and was very confused.我不断收到身份验证错误,并且非常困惑。

After a lot of time it turns out that os.getenv("username") wasn't returning the environment vairable but instead my name.很长一段时间后,事实证明 os.getenv("username") 没有返回环境变量,而是我的名字。 I checked the source code but in truth could not make sense of it lol.我检查了源代码,但实际上无法理解它,哈哈。 If anyone knows why this was the case and could tell me that would be awesome.如果有人知道为什么会这样并且可以告诉我那将是很棒的。

I know the module has something to do with the operating system but this was on the.env documentation so I'm just surprised it didn't work as expected.我知道该模块与操作系统有关,但这是在 .env 文档中,所以我很惊讶它没有按预期工作。

here is the code all though I doubt it will be that useful, fixed since last commit: https://github.com/shers003/firstRedditbot这是代码,尽管我怀疑它是否有用,自上次提交以来已修复: https://github.com/shers003/firstRedditbot

According to this page , username is a built-in environment variable in Windows.根据this pageusername是Windows中的内置环境变量。 The solution is to use a different name.解决方案是使用不同的名称。

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

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