Python os.getenvb() Method
Example
Print the value of the environment variable key "HOME", in bytes:
#Import os Library
import os
#print value of the environment variable key, in bytes
print (os.getenvb(b"HOME"))
Try it Yourself »
Definition and Usage
The os.getenvb()
method returns the value of the environment variable key, if it exists, in bytes.
Note: This method is available if supports_bytes_environ
is True. This is not available on Windows.
Syntax
os.getenvb(key, default)
Parameter Values
Parameter | Description |
---|---|
key | Required. A bytes object with the name of the environment variable |
default | Optional. Default value in case the key does not exist. If omitted, the value is 'None' |
Technical Details
Return Value: | A byte value, representing value of the
environment variable key. If key does not exists, it returns the value of the
default parameter |
---|---|
Python Version: | 3.2 |