I want to use python3 command line to run some scirpt that get some output. I can't import python scirpt because my code have to work with many of scripting writing in python independent of me and I can't do this manually. I want to run like this result:
sensor_name = "./sensors/" + sensor + ".py"
result = subprocess.run(['python3',sensor_name,'22','2','temperature'], stdout=subprocess.PIPE)
When arguments {22,2,temperature} is writing now manually. I want to replace this arguments with 1 variable like this :
result = subprocess.run(['python3',sensor_name, temp], stdout=subprocess.PIPE)
I trying to insert here list but it doesn't support this type of variable. I try to use string spliting commas but when I put string I get only 1 arguments. Script which I want to run looks like this :
if __name__=="__main__":
print(dht(*sys.argv[1:]))
And function dht :
def dht(dht_type,pin,quanity,quanity1):
Any suggestions how to deal with it ?