小编mpa*_*pag的帖子

python datetime.now()不从包含文件的函数头返回更新的时间戳

对datetime.now()的调用当前返回的时间与第一次调用时相同,即使几小时后调用也是如此.

我有以下代码.在first.py中

#!/usr/bin/env python
import sys
import time
import datetime as dt
import fns_print as pr
import fns_time as tm

def main(argv):
  pr.ts_print("STARTED")
  # do a bunch of other stuff that takes 10+ seconds
  pr.ts_print("Finished Download Pass")

if __name__ == "__main__":
  main(sys.argv)
Run Code Online (Sandbox Code Playgroud)

fns_print.py:

#!/usr/bin/env python
from __future__ import print_function
import fns_time as tme

def ts_print(string, **kwargs):
  """Print timestamped message to stdout and into log file"""
  print("{}: {}".format(tme.strTimeSt(),string),**kwargs)
  return True
Run Code Online (Sandbox Code Playgroud)

fns_time.py

#!/usr/bin/env python
import time
from datetime import datetime, tzinfo, timedelta …
Run Code Online (Sandbox Code Playgroud)

python datetime include

1
推荐指数
1
解决办法
1631
查看次数

标签 统计

datetime ×1

include ×1

python ×1