Created
October 27, 2018 21:02
-
-
Save heffcodex/d4fc9c6fb313651b59da98f32ef378a0 to your computer and use it in GitHub Desktop.
Generate some chinese "words"
This file contains 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
import io, random, argparse, time | |
# N words by CHARS length | |
def main(): | |
argp = argparse.ArgumentParser() | |
argp.add_argument('N', metavar='N', type=int) | |
argp.add_argument('CHARS', metavar='CHARS', type=int) | |
args = argp.parse_args() | |
with io.open('output.txt', 'w', encoding='utf-8') as f: | |
for n in range(0, args.N): | |
word = '' | |
for c in range(0, args.CHARS): | |
word += chr(random.randint(19968, 40959)) | |
f.write(word + '\n') | |
if __name__ == '__main__': | |
try: | |
main() | |
print('Done!') | |
finally: | |
time.sleep(1) | |
input('Press any key to exit...') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment