Develope/Python
Python code to create Numeric list
rootable
2019. 12. 26. 14:23
반응형
아래는 8자리 숫자형 리스트 파일를 생성하는 파이썬 코드이다.
길이가 길어지던지, 문자열이 포함된 리스트를 생성할 때도 코드를 조금만 변형하면 생성할 수 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | length=8 character="0123456789" temp_list = [0 for x in range(0,length)] crack_list=[] text = open('list.txt','w') for i in range(0,pow(10,8)): stringGen="".join([character[x] for x in temp_list]) text.write(stringGen+"\n") temp_list[-1]+=1 for x in range(length-1,0,-1): if temp_list[x] == len(character): temp_list[x-1]+=1 temp_list[x]=0 text.close() | cs |
반응형