0
안녕하세요 저는 파이썬에서 초보자이며 파일 조작에 정통하지 않습니다. 로깅을위한 python 스크립트를 작성하고 있습니다. 아래 코드는 내 코드입니다.파이썬에서 타임 스탬프로 폴더 생성
infile = open('/home/nitish/profiles/Site_info','r')
lines = infile.readlines()
folder_output = '/home/nitish/profiles/output/%s'%datetime.now().strftime('%Y-%m-%d-%H:%M:%S')
folder = open(folder_output,"w")
for index in range(len(lines)):
URL = lines[index]
cmd = "curl -L " +URL
curl = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
file_data = curl.stdout.read()
print file_data
filename = '/home/nitish/profiles/output/log-%s.html'%datetime.now().strftime('%Y-%m-%d-%H:%M:%S')
output = open(filename,"w")
output.write(file_data)
output.close()
folder.close()
infile.close()
나는 이것이 정확한지 잘 모릅니다. 스크립트가 실행될 때마다 timestamp가있는 새 폴더를 만들고 for 루프의 모든 출력을 타임 스탬프가있는 폴더에 넣으려고합니다. 당신이 파일이 아닌 폴더를 만들려고로 사전에 도움을
감사합니다 당신이 작동하지 않을 수 있도록 모든 URL에 줄 바꿈을 후행 한