Skip to content

Instantly share code, notes, and snippets.

@heffcodex
Created October 27, 2018 21:02
Show Gist options
  • Save heffcodex/d4fc9c6fb313651b59da98f32ef378a0 to your computer and use it in GitHub Desktop.
Save heffcodex/d4fc9c6fb313651b59da98f32ef378a0 to your computer and use it in GitHub Desktop.
Generate some chinese "words"
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