I would like to use regular expressions to extract information from some chat logs. The format of the lines that are processed is 03:22:32 PM <b>blcArmadillo</b>. I used the python type () command to find that the variable messages are a callable-iterator. My question is: how can I navigate the called iterator most efficiently? They look like arrays where you can just use an index? The only way I could find the “retrieval” of the data is to iterate over the return values and add them to the list, as shown below in the snipet code.
03:22:32 PM <b>blcArmadillo</b>
times = [] messages = re.compile(r'(?P<time>..:..:.. ..).*?<b>(?P<usrname>.*?):</b>').finditer(search) for result in messages: times.append(result.group('time'))
Is there a more efficient way to do this? Thanks for the help.
- . , , . , . :
for result in messages: times.append(result.group('time'))
, :
times = [result.group('time') for result in messages]
. , , . , , . , , , , , .
: , , , , .
Source: https://habr.com/ru/post/1707171/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1707166/pros-and-cons-for-prototyping-a-desktop-app-with-tcltk&usg=ALkJrhj_CUM57VZMsCQ0ijnUqebGPrfexACan Silverlight do the following? - silverlightCan client Flash (swf file) do the following? - flashHow to set default value for Access 2003 field using SQL? - sqlSerialize DetachedCriteria with nHibernate - c #Remote Control .NET and Delphi win32 - .netHow do I serialize an NHibernate DetachedCriteria object? - c #Best practices for deactivating SharePoint features - sharepointCould not get command line arguments correctly in C # - command-lineIP address changes automatically for default website in IIS - web-servicesAll Articles