python获取当前时间的长整型和字符格式串

python获取当前时间的长整型和字符格式串
from datetime import datetimenow datetime.now() # 获取当前时间的datetime对象 now_seconds round(now.timestamp()) # now.timestamp()会返回带毫秒的浮点数1782868575.267624比如now.timestamp()秒 now_str now.strftime(%Y-%m-%d %H:%M:%S)print(now_str)