Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
filter out a string
#1
Hello, I use code like this
cpu_temp2 = os.popen("vcgencmd measure_temp").readline()
to get the cpu temperture of the pi.It returns a string temp=55.6'C
Now I want to get rid of the temp= and 'C so that I can insert just the number eg, 55.6 to a database. How do I get rid of temp= and 'C?
I tried re.sub("\D", "" cpu_temp2) but it returns 556, How do I preserver the 55.6?
Thanks
Reply


Messages In This Thread
filter out a string - by tony1812 - Sep-13-2018, 11:20 PM
RE: filter out a string - by ichabod801 - Sep-14-2018, 02:22 AM
RE: filter out a string - by tony1812 - Sep-14-2018, 12:27 PM
RE: filter out a string - by volcano63 - Sep-14-2018, 04:17 PM
RE: filter out a string - by ichabod801 - Sep-14-2018, 01:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  filter just with the string word jacklee26 2 2,427 Feb-03-2020, 03:25 PM
Last Post: snippsat
  Converting query string as a condition for filter data. shah_entrance 1 1,818 Jan-14-2020, 09:22 AM
Last Post: perfringo
  I want to filter out words with one letter in a string (pig latin translator) po0te 1 2,135 Jan-08-2020, 08:02 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020