Python Forum
fastest way to record values between quotes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fastest way to record values between quotes
#3
Can't you match more directly?
>>> import re
>>> 
>>> line1 = '"tel 555-669", "duration 6", "number 2.", "Price 3.58"'
>>> r = re.search(r"(Price)\s(\d.\d+)", line1)
>>> d = r.groups()
>>> d
('Price', '3.58')
>>> d = dict([d])
>>> d
{'Price': '3.58'}
>>> d['Price']
'3.58'
>>> float(d['Price'])
3.58
Did also match Price so could make a dictionary.
pythonduffer Wrote:Then I inserted a couple of lines to force a delay.
Can use timeit that is made for measure execution of small code snippets.
Reply


Messages In This Thread
RE: fastest way to record values between quotes - by snippsat - Apr-14-2019, 06:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fastest way tkinter Quatrixouuu 2 470 Feb-19-2024, 07:20 AM
Last Post: Danishhafeez
  Last record in file doesn't write to newline gonksoup 3 517 Jan-22-2024, 12:56 PM
Last Post: deanhystad
  How do I stream and record at the same time with arducam? traderjoe 0 512 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  What is the fastest way to get all the frames from a video file? glorsh66 3 1,202 May-26-2023, 04:41 AM
Last Post: Gribouillis
  Fastest Way of Writing/Reading Data JamesA 1 2,244 Jul-27-2021, 03:52 PM
Last Post: Larz60+
  Two types of single quotes Led_Zeppelin 2 1,970 Mar-15-2021, 07:55 PM
Last Post: BashBedlam
  Only getting last record saved...Why Milfredo 10 4,553 Sep-10-2020, 03:00 AM
Last Post: Milfredo
  Quotes vs. no quotes around numbers Mark17 6 3,228 Aug-06-2020, 04:13 AM
Last Post: t4keheart
  how can we record a video file from our program output (moving object) Zhaleh 0 1,851 Aug-03-2020, 02:47 PM
Last Post: Zhaleh
  Fastest Method for Querying SQL Server with Python Pandas BuJayBelvin 7 7,073 Aug-02-2020, 06:21 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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