AttributeError:' str'对象没有属性' localtime'

时间:2016-05-20 04:21:10

标签: python-3.x

我通常有沙盒,我在那里尝试代码片段。

当我在沙箱中运行以下代码时,它按预期工作

 tuple_current_time = time.localtime(time.time())

    print("tuple_current_time = ", tuple_current_time) 

但是当我在我正在开发的模块中运行它时,我得到了错误

属性错误:' str'对象没有属性' localtime'

if not (sched_time) == "TIME":
    print("Its not equal", sched_time)
    #print ("Variable Type : ",  type (tuple_current_time))
    #Create a tuple of current time


    tuple_current_time = time.localtime(time.time())

    print("tuple_current_time = ", tuple_current_time)

    tuple_website = newtuple=(tuple_current_time[0], tuple_current_time[1],            tuple_current_time[2], sched_hour, sched_min, 0, 0, 0, 0)
    print("tuple_website = ", tuple_website)

    if tuple_website > tuple_current_time:
        #print("Website tuple is newer than current time tuple")
    else:
        #print("Current time tuple is newer than website time tuple")

任何人都可以建议我做错了吗?

由于

0 个答案:

没有答案