Skip to content

Instantly share code, notes, and snippets.

Created August 14, 2014 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/75163b5a8d22e1708790 to your computer and use it in GitHub Desktop.
Save anonymous/75163b5a8d22e1708790 to your computer and use it in GitHub Desktop.
#-*- coding:utf-8 -*-
import re
import random
import codecs
I=open('.\CET.txt','r')
O=open('.\CET.Shuffle.txt','w')
CET=I.read()
if CET[:3] == codecs.BOM_UTF8:
CET=CET[3:]
Match=re.findall(r'(^Q:.*$\s*^A.*$)',CET,re.M)
random.shuffle(Match)
Out=""
for Item in Match:
Out=Out+Item
Out=Out+'\r\n\r\n'
O.write(Out)
I.close()
O.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment