我是python的新手。我想知道如何从下面的logcat消息中区分两个logcat时间戳间隔以及x和y坐标。
我有一个文件,其中包含来自logcat的以下消息,它们表示如下
Date Time(HH:MM::SS:MS) ACTION_TYPE, (X,Y)
05-03 12:53:15.251 ACTION_MOVE, (596.00, 841.00)
05-03 12:53:15.268 ACTION_MOVE, (599.00, 847.00)
我想获得csv文件中的输出
timestampdiff(millsec), x_change,y_change
17,3.00,6.00
您可以使用regex解析文件(一旦读取)
import re
# example string from your file
s='05-03 12:53:15.251 ACTION_MOVE, (596.00, 841.00) '
# The unescaped round brackets will capture the numbers
r =re.match(r'd+-d+s+d+:d+:(d+.d+)s+[A-Z_]+,s+(d+.d+,s+d+.d+)', s)
r.groups(0) # Will output ('15.251',)
对所有需要的数字重复上述步骤,转换为十进制(或浮点)并计算差值。