我写了python脚本,我更改了变量名之一,代码工作正常,但是当我在调试模式下运行它时,我不断获取NameError更改了他的名字的变量,我试图进行“清理”该代码,也确实进行了同步,但仍然会发生。 “时间”被称为“ timeNow”,错误:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition
2017.3.1\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 1157, in do_it
result = pydevd_vars.evaluate_expression(self.thread_id,
self.frame_id, self.expression, self.doExec)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.1\helpers\pydev\_pydevd_bundle\pydevd_vars.py", line 345, in evaluate_expression
Exec(expression, updated_globals, frame.f_locals)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.1\helpers\pydev\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "<string>", line 1, in <module>
NameError: name 'timeNow' is not defined
会导致什么?
from datetime import datetime, timedelta
def print_users(user_dict, days):
time = datetime.now()
for key in user_dict:
if time - timedelta(days=days) > user_dict[key]:
print(key)
def run():
users_dict = get_user_dict
print_users(users_dict, args.days)
print("Finish")
if __name__ =='__main__':
run()