2018-09-06 16:42 - INFO - Coordinate: [-285.444793701, 1958.66479492, 175.649078369], End of execution.
2018-09-06 16:43 - INFO - Coordinate: [-301.866485596, 1959.87561035, 175.649200439], End of execution.
2018-09-06 16:44 - INFO - Coordinate: [-318.365051275, 1960.27978516, 175.646804815], End of execution.
2018-09-06 16:45 - INFO - Coordinate: [-334.736816406, 1961.48742676, 176.991455078], End of execution.
2018-09-06 16:46 - INFO - Coordinate: [-356.053833008, 1962.49230957, 176.991180429], End of execution.
2018-09-06 16:47 - INFO - Coordinate: [-370.848907471, 1962.69274902, 176.989471436], End of execution.
2018-09-06 16:48 - INFO - Coordinate: [-388.050415039, 1963.19372559, 178.462493896], End of execution.
提取代码如下
# key words to extract the coordinate
str_start = "["
str_end = "]"
f_orig = open('/home/yasin/test_coordinate.txt') # original file
f_coord = open('coordinate_save.txt', 'w') # target file used to save
line = f_orig.readline()
while line:
# find index according to the key words
index_start = line.find(str_start)
index_end = line.find(str_end)
text = line[index_start : index_end]
if text != '':
# If there is more than one [], we can use "Coordinate" and "End" as str_start and str_end
f_coord.write(str(line[index_start + 1 : index_end]) + '\n')
line = f_orig.readline()
f_orig.close()
f_coord.close()