共计 688 个字符,预计需要花费 2 分钟才能阅读完成。
sql = "update table1 set ppid=\'{}\’, updatetime=\'{}\’ where name=\'{}\’".format(ppid,NOW(),row[1])
老是提示 NameError: name \’NOW\’ is not defined
啥情况啊
已经 import time 了啊 updatetime 字段设为 datetime 类型了
import time
current_time = time.strftime(\’%Y-%m-%d %H:%M:%S\’)# 格式化当前时间
sql = "update table1 set ppid=\'{}\’, updatetime=\'{}\’ where name=\'{}\’".format(ppid, current_time, row[1])
import timecurrent_time = time.strftime(\’%Y-%m-%d %H:%M:%S\’)# 格式化当前时间 sql = "update table1 set ppid=\'{}\’, updatetime=\'{}\’ where name=\'{}\’".format(ppid, current_time, row[1]) 复制代码
waiwaiwq 发表于 2023-11-26 07:37
import time
current_time = time.strftime(\’%Y-%m-%d %H:%M:%S\’)# 格式化当前时间
兄弟是高手 感谢!
没有 NOW 这个函数,你先格式化一下当前日期就好
now() 是 mysql 中的函数,直接拼字符串里面
mishi 发表于 2023-11-26 07:44
兄弟是高手 感谢!
搞定了吗