31 lines
656 B
Python
31 lines
656 B
Python
import os
|
|
import sys
|
|
|
|
#1.3
|
|
ENV = sorted(os.environ.items())
|
|
|
|
def filter_dict(filtered_dict, strings):
|
|
result = dict()
|
|
for k,v in filtered_dict.items():
|
|
if any(x in k for x in strings):
|
|
result[k] = v
|
|
return result
|
|
|
|
def print_dict(printed_dict):
|
|
for k,v in printed_dict.items():
|
|
print(k + ": " + v, sep="\n")
|
|
|
|
def main():
|
|
print(ENV)
|
|
#1.1
|
|
print('zmienne środowiskowe:')
|
|
print_dict(ENV)
|
|
|
|
#1.2
|
|
filter_strings = sys.argv[1:]
|
|
print('zmienne środowiskowe filtrowane przez:', ", ".join(filter_strings))
|
|
print_dict(filter_dict(ENV, filter_strings))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |