import random import sys import pandas as pd DW = pd.read_csv('pinyin.wordlist') SEPARATOR = [ '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~' ] LENGTH = int(sys.argv[1]) if len(sys.argv) > 1 else 6 CHT = [] WORD = [] for i in range(LENGTH): ID = random.SystemRandom().randint(0, 8191) CHT.append(DW['cht'].values[ID]) WORD.append(DW['word'].values[ID]) ID = random.SystemRandom().randint(0, 31) print(' '.join(CHT)) print(SEPARATOR[ID].join(WORD))