Home > other >  Python is how to deal with the pace of the seconds
Python is how to deal with the pace of the seconds

Time:09-19

Consult everybody,
I have a demand, want to find the pace of the table, which is more than 10 seconds, pace for data format and 5 '22 "
The following two data, for example, the last column is the pace, trying to find more than 8 'record, please give directions,
Xiu-jin li 2019/11/17 2019/11/17 get 4.16 7 '10 "
Chen Yanru 2019/2/26 2019/2/26 18:04 5.6 8 '34 "

Thank you,

CodePudding user response:

 
S=[" 'xiu-jin li 2019/11/17 2019/11/17 get 4.16 7' 10 "" ',
"' Chen Yanru 2019/2/26 2019/2/26 18:04 5.6 8 '34']
"Print (s)
For s1 in s:
If the int (s1. The split (" ") [1]. The split (" '") [0]) & gt;=8:
Print (s1)

CodePudding user response:

 
If __name__=="__main__" :
S=[" 'xiu-jin li 2019/11/17 2019/11/17 get 4.16 7' 10 "" ',
"' Chen Yanru 2019/2/26 2019/2/26 18:04 5.6 8 '34']
"Print (s)
For s1 in s:
If the int (s1 [s1 rindex (' ') : s1. Rindex (' \ ')]) & gt;=8:
Print (s1)

CodePudding user response:

This requirement description is a bit fuzzy, so we have to assume that is greater than eight points to 10 seconds, raw data is done, the final results to remove "\ n" can (this step is abbreviated), similar to other data, first consideration should be separator is quick and easy, regular a little complicated, plus check beyond this code,
 import re 
Pattern="(*) [^/: 0-9] [] [] (^) (*) (*) [^] [] [] ([^] *) (*) [^] [] ([0-9] *) ['] ([0-9] *) [\]" "
Datas=[" 'xiu-jin li 2019/11/17 2019/11/17 get 4.16 7' 10 "
Chen Yanru 2019/2/26 2019/2/26 18:04 8 '34 "5.6"']
Counter=0
For the data in datas:
Results=re. The.findall (pattern, data, re. M | re S | re... I)
If the results is not None and len (results) & gt; 0:
For the result in the results:
Counter=counter + 1
Minutes=int (the result of [2])
Seconds=int (the result of [1])
If minutes>=8 and seconds>=10:
Print (" Records of time>=8 '10 \ ":" + result [0] + ":" + result [2] + "minutes", the result of [1] + "seconds")
Print (STR (counter) + "" + STR (result))

  • Related