简体   繁体   中英

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. 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. 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.

here is the code all though I doubt it will be that useful, fixed since last commit: https://github.com/shers003/firstRedditbot

According to this page , username is a built-in environment variable in Windows. The solution is to use a different name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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