3

I need a sample program that will put the current CPU MHz in a variable with python. I prefer a short compact program. Thanks in advance.

1
  • But do you want to check the CPU speed, or do you want to change the speed on the fly? – tlfong01 Oct 28 '19 at 1:01
4

This is four lines, but here it is anyways. Probably isn't the best way, though. (oh, and in your script remember to use the shebang for python3)

from os import popen
str=popen("vcgencmd measure_clock arm").read()
str = str[str.find("=")+1:-7]
print(str)
1
  • Thank you so much for your help! – Luke Flowers Oct 29 '19 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.