python - How to pass a list as an environment variable? -
i use list part of python program, , wanted convert environment variable.
so, it's this:
list1 = ['a.1','b.2','c.3'] items in list1: alpha,number = items.split('.') print(alpha,number)
which gives me, expected:
a 1 b 2 c 3
but when try set environment variable, as:
export list_items = 'a.1', 'b.2', 'c.3'
and do:
list1 = [os.environ.get("list_items")] items in list1: alpha,number = items.split('.') print(alpha,number)
i error: valueerror: many values unpack
how modify way pass list, or have same output without using env variables?
i'm not sure why you'd through environment variables, can this:
export list_items ="a.1 b.2 c.3"
and in python:
list1 = [i.split(".") in os.environ.get("list_items").split(" ")] k, v in list1: print(k, v)
Comments
Post a Comment