Python时间戳互转

#推荐
Python时间戳互转

2026-03-17 2
[!--dianshu--] C币
VIP折扣
    折扣详情
  • 体验VIP会员

    免费

  • 月卡VIP会员

    免费

  • 年卡VIP会员

    免费

  • 永久VIP会员

    免费

查看演示
下载不了?请联系网站客服提交链接错误!
TAG标签: 安装指导

#推荐
Python时间戳互转

2026-03-17 php教程 9999 2
郑重承诺丨总裁主题提供安全交易、信息保真!
TAG标签:
安装指导
[!--dianshu--] C币
VIP权限详情
    会员权限详情
  • 体验VIP会员

    免费

  • 月卡VIP会员

    免费

  • 年卡VIP会员

    免费

  • 永久VIP会员

    免费

开通VIP尊享优惠特权
立即下载 等待添加 升级会员 最新活动
微信扫码咨询 微信扫码咨询

联系电话:18888888888

进入TA的商铺 联系官方客服
详情介绍

欢迎!我白天是个邮递员,晚上就是个有抱负的演员。这是我的网站。我住在天朝的帝都,有条叫做Jack的狗。

查询时间:可查询当前时间与时间戳时间戳转时间:在前面输入框中输入时间戳点击按钮可转成时间时间转时间戳:在前面输入框中输入时间点击按钮可转成时间戳,时间格式如果不知道可复制查询时间中的时间格式

import timeimport osimport tkinter as tkimport threadingimport datetime  def sjc():    t.delete(1.0, tk.END)    i = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')    print(i)    t.insert('end', '当前时间:')    t.insert(tk.INSERT, '\n')    t.insert('end', i)    t.insert(tk.INSERT, '\n')    # 转换成时间数组    timeArray = time.strptime(i, "%Y-%m-%d %H:%M:%S")    # 转换成时间戳    timestamp = int(time.mktime(timeArray))    print(timestamp)    t.insert('end', '当前时间戳:')    t.insert('end', timestamp)    t.insert(tk.INSERT, '\n')     # utc5_beginTime = (int(timestamp/86400)+1)*86400+18000    # utc5_endTime = utc5_beginTime+86400*(int(hdts)-1)+79200    # print("----------utc-5")    # print(utc5_beginTime)    # print(utc5_endTime)    # t.insert('end',"----------utc-5")    # t.insert(tk.INSERT, '\n')    # t.insert('end', utc5_beginTime)    # t.insert(tk.INSERT, '\n')    # t.insert('end', utc5_endTime)    # t.insert(tk.INSERT, '\n')    # utc2_beginTime = (int(timestamp/86400)+1)*86400-7200    # utc2_endTime = utc2_beginTime+86400*(int(hdts)-1)+79200    # print("----------utc+2")    # print(utc2_beginTime)    # print(utc2_endTime)    # t.insert('end',"----------utc+2")    # t.insert(tk.INSERT, '\n')    # t.insert('end', utc2_beginTime)    # t.insert(tk.INSERT, '\n')    # t.insert('end', utc2_endTime)    # t.insert(tk.INSERT, '\n')    # utc8_beginTime = (int(timestamp/86400)+1)*86400-28800    # utc8_endTime = utc2_beginTime+86400*(int(hdts)-1)+79200    # print("----------utc+8")    # print(utc8_beginTime)    # print(utc8_endTime)    # t.insert('end',"----------utc+8")    # t.insert(tk.INSERT, '\n')    # t.insert('end', utc8_beginTime)    # t.insert(tk.INSERT, '\n')    # t.insert('end', utc8_endTime)    # t.insert(tk.INSERT, '\n')def zsj():    hdts = txt.get()    if hdts == "输入时间戳":        t.insert('end', '输入时间戳')        t.insert(tk.INSERT, '\n')        return    t.insert('end', '时间戳:')    t.insert('end', hdts)    t.insert(tk.INSERT, '\n')    # 将时间戳转换为datetime对象    dt_object = datetime.datetime.fromtimestamp(int(hdts))     # 格式化输出时间    formatted_time = dt_object.strftime("%Y-%m-%d %H:%M:%S")     print("转换后的时间:", formatted_time)    t.insert('end', '时间:')    t.insert('end', formatted_time)    t.insert(tk.INSERT, '\n')def zsjc():    sj = txt1.get()    if sj == None:        t.insert('end', '输入时间')        t.insert(tk.INSERT, '\n')        print('输入时间')        return    t.insert('end', '时间:')    t.insert('end', sj)    t.insert(tk.INSERT, '\n')    # 转换成时间数组    timeArray = time.strptime(sj, "%Y-%m-%d %H:%M:%S")    print(timeArray)    # 转换成时间戳    timestamp = int(time.mktime(timeArray))    print(timestamp)    t.insert('end', '时间戳:')    t.insert('end', timestamp)    t.insert(tk.INSERT, '\n') def thread_it(func, *args):    '''将函数打包进线程'''    k = threading.Thread(target=func, args=args)    k.setDaemon(True)    k.start()  def get_servertime(self):    """    获取服务器当前时间    :return:当前服务器时间戳    """    req_body = self.get_request_body('gmGetServerTime')    rsp = self.send_http_request(req_body).json()    print(rsp['data']['serverTime'])    return rsp['data']['serverTime']  if __name__ == '__main__':    window = tk.Tk()    window.title('sjc')    window.geometry("200x300")    t = tk.Text(window, width='250', height=15, bg='LightBlue')    t.pack(side='bottom')    btn1 = tk.Button(window, text="查询时间", bg="orange", command=lambda: thread_it(sjc))    btn1.place(x=110, y=5)    btn2 = tk.Button(window, text="时间戳转时间", bg="orange", command=lambda: thread_it(zsj))    btn2.place(x=110, y=35)    btn3 = tk.Button(window, text="时间转时间戳", bg="orange", command=lambda: thread_it(zsjc))    btn3.place(x=110, y=65)    txt = tk.Entry(window, width=13)    txt.place(x=10, y=35)    txt.insert('end', 2)    txt1 = tk.Entry(window, width=13)    txt1.place(x=10, y=65)    txt1.insert('end','')    # wz1 = tk.Label(window, text='输入开服天数:')    # wz1.place(x=0, y=0)    window.mainloop()

下载地址
  • 提取密码
  • 1561
  • 解压密码
  • DWQwdewq
    立即免费下载
    Python时间戳互转
收藏 (15) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 ()

所有文章为演示数据,不提供下载地址,版权归原作者所有,仅提供演示效果!

CMS主题网 php教程 Python时间戳互转 /showinfo-48-167-0.html

我们只做高端Wordpress主题开发!

常见问题
  • 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
查看详情
  • 最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用
查看详情

相关文章

帝国CMS二次开发 函数文件      PRinterror()/e/class/connect.phpline 132query()/e/class/db_sql.php line 10fetch1()/e/class/db_sql.php line 30fetch()/e/class/db_sql.php line 22checklevel()/e/class/functions.php line 3414insert_dolog()/e/class/functions.php line 3...
#推荐
2026-03-17 14 C币
帝国CMS8.0父子信息调用方      帝国CMS8.0版新增父子信息功能,让一条信息也能成为一个信息、一个栏目、一个专题、甚至一个网站。本文共有四个部分:一、父子信息功能使用流程。二、调用子信息:可以用索引灵动标签调用。三、父子信息列表访问地址的语法说明。四、进阶:调用当前父子信息...
#推荐
2026-03-17 4 C币
帝国CMS判断当前数据库是      有时候我们需要判断数据库是否包含某字段,就可以使用下面这段SQL语法,$fr=$empire->fetch1("SELECT COUNT(*) AS column_exists FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$infotb' AND COLUMN_NAME = 'money'");if($fr[&...
#推荐
2026-03-17 4 C币
Python开发一个ChatGPT GU      1、首先去下载这个ChatGPT库,用到的库是这个:https://github.com/acheong08/ChatGPT2、安装这个ChatGPT库:pip3 install revChatGPT==0.0.a423、同目录还需要一个“config.json”:{    "session_token": "",    "cf_clearance": "",    "user_agent": "
#推荐
2026-03-17 4 C币
使用CSS Grid Generator拖      如果你是CSS小白,不会使用复杂的UI框架,又需要开发一个响应式网站,那么我的站长站推荐你使用CSS Grid Generator,直接拖拽网格,就可以立即生成响应式CSS代码,复制到自己项目即可使用。使用方法1、首先根据你的项目需求,生成指定的列数和网格数量2、然后拖到...
#推荐
2026-03-17 3 C币
Playwright闲鱼智能监控机      项目介绍Playwright闲鱼智能监控机器人项目,基于 Playwright 和AI过滤分析的闲鱼多任务实时监控与智能分析工具,配备了功能完善的 Web 管理界面。可以实时按规则抓取闲鱼商品,垃圾佬的最爱。闲鱼智能监控机器人:https://github.com/dingyufei615/ai-goof...
#推荐
2026-03-17 3 C币
过年给网站加一对灯笼CSS      马上快过年了,给网站加一对红灯笼,这样才有过年的喜庆劲儿。灯笼是代码生成的无需图片,而且还会摆动。使用方法把HTML下面代码粘贴到网页BODY内任意位子都可以。灯笼的位子可以微调.deng-box的left和right数值。CSS代码<!-- 灯笼代码 --><div class="de...
#推荐
2026-03-17 3 C币
ajax上传文件进度条功能示      ajax上传文件时,有时比较耗时,需要在界面上显示下进度信息,获取ajaxSettings中的xhr对象,为它的upload属性绑定progress事件的处理函数前端代码<!DOCTYPE html><html><head><meta charset="utf8"><title>test upload</title><!--jquery--><script src="h...
#推荐
2026-03-17 3 C币