'''
写日志函数
:param username:用户名
:param operation:用户的操作信息
:return:
'''
w_time = time.strftime('%Y-%m-%d %H%M%S')
with open('log.txt','a+') as fw:
log_content = '%s %s %s \n'%(w_time,username,operation)
fw.write(log_content)
希望对你有帮助!
应该是split后生成的列表的原始超过2个了。看下面的简单的例子就知道了。其实应该看一下生成后的长度,做个保护,否则像你这种赋值,只要列表长度不为2,都会异常。
>>>x=[1,2,3]
>>>a,b=x
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ValueError: too many values to unpack