Skip to content

Instantly share code, notes, and snippets.

@racterub
Created March 14, 2017 13:40
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 racterub/2ead6cc2fc1f8f3099ef8d79b4a2930a to your computer and use it in GitHub Desktop.
Save racterub/2ead6cc2fc1f8f3099ef8d79b4a2930a to your computer and use it in GitHub Desktop.
抽順序
#!/usr/lib/env python
import random
f = open('data', 'r')
a = {}
for line in f:
k, v = line.strip().split('=')
a[k.strip()] = v.strip()
f.close()
r = open('result', 'w')
for i in random.sample(a.items(), 6):
ni = list(i)
if len(ni[1].split(',')) >= 5:
r.write(str(ni) + " " + str("Length:5 min") + "\n")
else:
r.write(str(ni) + " " + str("Length:4 min") + "\n")
r.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment