Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # extract_img_hw_sort.py
- import random
- ppp='''
- ABC123 great +++ Y2K ??? abc 001 $$$ 1920 X 1080 XYZ123 !!! ### yes 250 XXX
- 1440 X 960 ### WOW! Python xyz 250 $$$ !!! ??? great
- zzz demo XXX abc *** hello 800 X 1200
- 123 100 250 $$$ hello XYZ123 great +++ abc 1280 X 1024 zzz
- test abc *** yes Y2K ### 854 X 1280
- 250 test 123 xyz Python 2560 X 1440 +++ ### !!! 100 zzz ABC123 hello 099
- 1600 X 1200 123 099 $$$ Python abc great ABC123 *** hello +++ Y2K
- ??? demo xyz great ### ABC123 3000 X 2000 +++ XYZ123 test WOW! 001 haha XXX 123 Python
- XXX zzz 1080 X 1200 Python $$$ 123 ABC123 hello 250 ###
- 099 +++ zzz 900 X 900 100 ABC123 ### test *** xyz 250
- '''.strip().splitlines()
- zzz=[]
- for z in ppp:
- if 'X' in z:
- print z
- z=z.split()
- x=z.index('X')
- z=[int(z[x-1]),int(z[x+1])]
- zzz.append(z)
- print z
- print
- for z in range(len(zzz)-1,0,-1):
- if zzz.count(zzz[z]) > 1:
- del zzz[z]
- zzz.sort(key=lambda zzz: zzz[1])
- for z in zzz[::-1]: print z
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement