-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPythonChallenge9.py
28 lines (27 loc) · 956 Bytes
/
PythonChallenge9.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
# encoding:utf-8
# -*- Mode: Python -*-
# Author: Soros Liu <[email protected]>
# ==================================================================================================
# Copyright 2016 by Soros Liu
#
# All Rights Reserved
"""
still PIL library
get the first and second line data and connect dots together
"""
import re
from PIL import ImageDraw, Image
__author__ = 'Soros Liu'
with open('return_good.html') as f:
source = f.read()
source = ''.join(source.split('\n'))
content = re.findall(r'(<!\-\-.*?\-\->)', source)[1]
first = list(map(int, re.findall(r'first:(.*)second', content)[0].split(',')))
second = list(map(int, re.findall(r'second:(.*)-->', content)[0].split(',')))
img = Image.open('good.jpg')
new_img = Image.new(img.mode, img.size)
draw = ImageDraw.Draw(new_img)
draw.line(first)
draw.line(second)
new_img.show(title='result')