代码如下: from datetime import datetime now=datetime.now() print(now) now.strftime("%x") now.strftime("%X") 运行结果: