用户创建的日志文件

时间:2016-08-16 02:08:16

标签: python logfiles

我收到TypeError: object of type file' has no len() 我已经将问题追溯到执行时建立的路径。

在“temp = os.path.join(savePath,files)”中的“savePath”减速或使用中纠正此错误,我缺少什么?

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()

0 个答案:

没有答案