반응형
file write ][ 랜덤하게 파일을 생성해서 임의 데이터 쓰기
import random
data = "00000000"
ascii_str1 = ['a', 'b', 'c', 'd', 'e' , 'f' , 'g' ,'h' , 'i' , 'j' ,'k', 'l' ,'m' ,'n' ]
ascii_str2 = ['o', 'p', 'q', 'r', 's' , 't' , 'u' ,'v' , 'w' , 'x' ,'y', 'z' ]
for t in range(1,100000000):
rand_str1 = random.choice(ascii_str1)
rand_str2 = random.choice(ascii_str2)
filename = "d:\\test" + rand_str1 + rand_str2 + "%d.txt" % t
print filename
f = open(filename, 'a+')
for i in range(1, 500):
data = data + "%d aaaaa.\n" % i
f.write(data)
data = ""
f.close()
반응형
'Python > 0x07-file' 카테고리의 다른 글
| file writer][ csv 형식으로 파일 출력하기 (0) | 2019.09.06 |
|---|---|
| directory scan][ 지정 디렉토리의 모든 sub directory와 총 파일 개수 가져오기 (0) | 2019.08.29 |
| file attr class ][ 파일 속성 가져오기 (0) | 2017.10.16 |
| file write class ][ 추상 클래스 사용하기 (0) | 2017.10.16 |
| python으로 짠 가벼운 filedownload (0) | 2015.11.30 |