이 프로그램은 문자 조합을 생성하고 단어인지 확인하기 위해 프로그램을 작성하지만 초당 몇 단어 만 생성하는 속도가 매우 느립니다. 매우 느린 이유를 말해, 내가 더 빨리 만들 필요가 무엇인지하시기 바랍니다python 프로그램이 매우 느림
import itertools
for p1 in itertools.combinations('abcdefghijklmnopqrstuvwxyz', 4):
with open('/Users/kyle/Documents/english words.txt') as word_file:
english_words = set(word.strip().lower() for word in word_file)
def is_english_word(word):
return word.lower() in english_words
print ''.join(p1),"is", is_english_word(''.join(p1))
단어 목록의 크기는 얼마나됩니까? 조합 당 한 번 읽는 중입니다. –
단어 목록은 모든 영어 단어 목록입니다. –