나는 TypeError: object of type file' has no len()
을 얻고 있습니다. 실행시 설정된 경로로 이슈를 추적했습니다.사용자가 생성 한 로그 파일
"savePath"감속 또는 "temp = os.path.join (savePath, files)"내에서의 사용 내에서 발견 된 오류를 수정하려면 무엇이 누락 되었습니까?
def printTime(time):
savePath = "C:\Users\Nicholas\Documents"
files = open("LogInLog.txt", "a")
temp = os.path.join(savePath, files)
files.write("A LogIn occured.")
files.write(time)
print files.read
files.close
main()
전체 프로그램은 참조를 위해 다음과 같습니다 : 여기
from time import strftime
import os.path
def main():
getTime()
def getTime():
time = strftime("%Y-%m-%d %I:%M:%S")
printTime(time)
def printTime(time):
savePath = "C:\Users\Nicholas\Documents"
files = open("LogInLog.txt", "a")
temp = os.path.join(savePath, files)
files.write("A LogIn occured.")
files.write(time)
print files.read
files.close
main()
당신은 참조해야 https://docs.python.org/2/library/logging.html – pigletfly
적어도 _what_ 말, 문제가 아닙니다 "무언가는'printTime 함수는()가'기능은 내 잘못 가고있다" 잘못되고있다. – Julien
죄송합니다 내 질문을 편집 ... 내가 뭘하려고했는지 자체 설명했다 생각 ...하지만 "가져 오기 os.path"가져 오기를 너무 많이 사용하지 않은 및 저장된 파일을 저장하는 데 문제가 있습니다. 코드 내의 디렉토리 –