Python 获取当前时间或当前时间戳,通过时间戳获取hash
Python 获取 时间 通过 当前 HASH
2023-09-11 14:14:44 时间
源码:
#!/usr/bin/python3
import time
# 格式化成2016-03-20 11:45:39形式
print (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
# 格式化成Sat Mar 28 22:24:24 2016形式
print (time.strftime("%a %b %d %H:%M:%S %Y", time.localtime()))
# 将格式字符串转换为时间戳
a = "Sat Mar 28 22:24:24 2016"
print (time.mktime(time.strptime(a,"%a %b %d %H:%M:%S %Y")))
通过时间戳获取hash
import datetime
import hashlib
print(str(datetime.datetime.now()))
hash_value = hashlib.sha256(str(datetime.datetime.now()).encode("utf8"))
print(hash_value.hexdigest())
结果:
2016-04-07 10:29:46
Thu Apr 07 10:29:46 2016
1459175064.0
2020-10-29 11:24:56.911750
155dfb90d83ccfa74217c1dac48f1d03e6ea1a323f16cf3d0b8c0450d091092d
相关文章
- Python爬虫之反爬虫(随机user-agent,获取代理ip,检测代理ip可用性)
- 【Python成长之路】python并发学习:多进程与多线程的用法及场景介绍
- python开发笔记-类
- Python 装饰器装饰类中的方法
- Python 日期和时间_python 当前日期时间_python日期格式化
- Python 日期和时间_python 当前日期时间_python日期格式化
- python使用urllib库发送http请求示例:获取百度人工智能服务平台Access Token代码示例
- Python编程:利用python编程实现对基于时间序列的数据(dataframe格式)按照指定时间范围进行单方向关联,不存在的日期补充为默认的NaN
- Python语言学习:在python中,如何获取变量的本身字符串名字而非其值/内容及其应用(在代码中如何查找同值的所有变量名)
- Python语言学习之文件夹那些事:python和文件夹的使用方法之详细攻略
- Python编程:利用python编程实现对基于时间序列的数据(dataframe格式)按照指定时间范围进行单方向关联,不存在的日期补充为默认的NaN
- Python编程语言学习:python中与数字相关的函数(取整等)、案例应用之详细攻略
- Python语言学习:三种随机函数random.seed()、numpy.random.seed()、set_random_seed()及random_normal的简介、使用方法(固定种子)详细攻略
- 〖Python自动化办公篇㉑〗- python实现邮件自动化 - 定时发送邮件
- 从零开始学python | 使用Python映射,过滤和缩减函数:所有您需要知道的
- Elasticsearch 基本介绍及其与 Python 的对接实现
- Python getattr() 函数==>获取一个对象的属性值
- Python编程:获取类实例对象的元素
- python 调用图灵机器人api实现简单的人机交互
- Python使用4个空格替换Tab, TabError: inconsistent use of tabs and spaces in indentation。
- 雅虎财经数据python 网络爬虫stock股票 用 Python 通过雅虎财经获取股票数据
- python扫描proxy并获取可用代理ip列表
- 多版本Python共存时pip给指定版本的python安装package的方法
- 如何在本机执行 pyscript (在网页中执行python)
- Python-OpenCV图像处理-10-直方图的操作
- 【Python基础】python爬虫之异步网络爬虫ǃ
- keras-yolo3:python库之keras-yolo3的简介、安装、使用方法详细攻略
- Python(2):字符串
- 【Python实战】 ---- python 自带的 venv 虚拟环境更新 pip 失败
- 关于粉丝需要编译python版本的opencv-cuda11的方法(在ubuntu22.04平台编译,python3.6,cuda11.7)