Created
June 29, 2012 05:35
-
-
Save methane/3016017 to your computer and use it in GitHub Desktop.
シリアルコード発行用スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import random | |
| import sys | |
| from glob import glob | |
| import os | |
| BASE = os.path.dirname(__file__) | |
| CHARS = 'ABCDEFGHJKMNPQRSTUVWXYZ23456789' | |
| N = int(sys.argv[1]) | |
| M = int(sys.argv[2]) | |
| used = set() | |
| for fn in glob(BASE + '/code/*.txt'): | |
| with open(fn) as f: | |
| for code in f: | |
| used.add(code.strip()) | |
| m = 0 | |
| while m < M: | |
| c = ''.join([random.choice(CHARS) for _ in xrange(N)]) | |
| if c not in used: | |
| m += 1 | |
| used.add(c) | |
| print c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment