os.system
doesn't returns the output, use subprocess.check_output
for that.
How to assign output of os.system to a variable [duplicate]
質問
I want to run this command from python
/opt/vc/bin/vcgencmd measure_temp
when I run it in python it prints the temperature to the screen and returns 0. When I try to assign it to a variable it assigns 0 too.
>>> import os
>>> os.system('/opt/vc/bin/vcgencmd measure_temp')
temp=42.8'C
0
>>> temp=os.system('/opt/vc/bin/vcgencmd measure_temp')
temp=42.8'C
>>> temp
0
>>>
How can I run this command in python and assign the actual temperature to a variable?
解決
所属していません StackOverflow