Untitled

mail@pastecode.io avatar
unknown
plain_text
4 days ago
507 B
3
Indexable
Never
    with open(dotenv_path) as f:
        for line in f:
            # Strip whitespace and ignore comments
            line = line.strip()
            if not line or line.startswith('#'):
                continue
            
            # Split the key and value
            key, value = line.split('=', 1)
            key = key.strip()
            value = value.strip().strip('"').strip("'")  # Remove extra spaces and quotes

            # Set the environment variable
            os.environ[key] = value
Leave a Comment