二手产品经理

二手产品经理

THIS IS RENO

environ - 70 days - online learning python for 100 days

Record#

Today I learned about environ. In replit, you can create a Secrets called password, which is essentially the same as environ.

In the code, you can access it by using os.environ['password']. The advantage of environ is that it stores sensitive information directly in the system instead of exposing it in the code. This way, when sharing the code, the crucial content will not be leaked.

As an exercise for today, I will create a login interface. You can create accounts and passwords for two different users and display different welcome messages based on the logged-in user. This allows for user authentication and personalized welcome experience.

CODE#

import os

adminpass = os.environ['adminpass']
normiepass = os.environ['normiepass']

print("🌟Login System🌟")

Username = input("Username > ")
Password = input("Password > ")

if Username == "admin":
  if Password == adminpass:
    print("Hello admin'")
  else:
    print("Better luck next time")
elif Username == "normie":
  if Password == normiepass:
    print("Hello normie'")
  else:
    print("Better luck next time")
else:
  print("Better luck next time")

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.