Single

[INSHack2019]Drone Motion1 min read

题目下载

一道坐标题,通过正则匹配提取坐标,画图即可。要注意的是,因为是画图,所以每个坐标每一位要加上前面的所有坐标。

import re

import matplotlib.pyplot as plt
x = []
y = []
z = []
a = []
x2,y2,z2=0,0,0
lines = open("sensors.log").readlines()
for line in lines:
    a.append("".join(re.findall("\[drone\]\(DEBUG\)> dir: \(x=(.*?),y=",line)))
for i in a:
    if i != '':
        x2+=float(i)
        x.append(float(x2))
a.clear()
for line in lines:
    a.append("".join(re.findall("\[drone\]\(DEBUG\)> dir: \(x=.*?,y=(.*?),z=",line)))
for i in a:
    if i != '':
        y2+=float(i)
        y.append(float(y2))
a.clear()
for line in lines:
    a.append("".join(re.findall("\[drone\]\(DEBUG\)> dir: \(x=.*?,y=.*?,z=(.*?)\)",line)))
for i in a:
    if i != '':
        z2+=float(i)
        z.append(float(z2))
ax = plt.plot(x, y,'-')
plt.axis('equal')
plt.savefig("test.png", dpi=1000)

plot函数作图(横纵坐标,定义线形):

plt.plot(x, y,'-')

避免比例压缩为椭圆:

plt.axis('equal')

保存为test.png,有则覆盖,分辨率1000:

plt.savefig("test.png", dpi=1000)

(感谢兰德师傅帮我瞅出来flag

⚪参考:

python-matplotlib绘图笔记

https://blog.csdn.net/guoziqing506/article/details/78975150

https://zhuanlan.zhihu.com/p/33270402