import time

import pandas as pd

# def writeaa():
#     detailList=[]
#     aa={
#         'id':3,
#         'name':'qqqwe'
#     }
#     detailList.append(aa)
#     writerToExcel(detailList)
# 将数据追加到excel
# def writerToExcel(detailList):
#     # filename='baidu搜索.xlsx'
#     # 读取已存在的xlsx文件
#     existing_data = pd.read_excel(filename,engine='openpyxl')
#     # 创建新的数据
#     new_data = pd.DataFrame(data=detailList)
#     # 将新数据添加到现有数据的末尾
#     combined_data = existing_data.append(new_data, ignore_index=True)
#     # 将结果写入到xlsx文件
#     combined_data.to_excel(filename, index=False)
#
# from openpyxl import Workbook
#
# if __name__ == '__main__':
#     filename='test1.xlsx'
#     # # 创建一个工作簿
#     workbook = Workbook(filename)
#     workbook.save(filename)
#     writeaa()

# gpdm = '01109.HK'
# if 'HK' in str(gpdm):
#     tmp_g = str(gpdm).split('.')[0]
#     if len(tmp_g) == 5:
#         gpdm = str(gpdm)[1:]
#         print(gpdm)
#     else:
#         pass

from base.BaseCore import BaseCore
baseCore = BaseCore()
r = baseCore.r

# #自增并设置过期时间
# while True:
#     key = 'mykey'
#     expiration_time = 60  # 设置过期时间 60秒
#     #设置自增
#     r.incr(key)
#
#
#
#     value = int(r.get(key).decode())
#
#     if value > 10:
#         print(value)
#         # 设置过期时间
#         r.expire(key, expiration_time)
#
#         time.sleep(70)
#         print('------------------')
#         continue
#     # print(value)
#
#     print("==========")
# expiration_time = 60
# # 创建PubSub对象
# p = r.pubsub()
#
# # 订阅过期事件
# p.psubscribe('__keyevent@6__:expired')
# aa = p.listen()
# # 监听过期事件
# for message in p.listen():
#     if message['type'] == 'pmessage':
#         expired_key = message['data'].decode()
#         print('过期的key:', expired_key)
#         if expired_key == 'counter':
#             # 执行重置操作
#             r.set('counter', 0)
#             print('计数器已重置为0')
#             # 设置自增
#             r.incr('counter')
#             # 设置过期时间
#             r.expire('counter', expiration_time)

for i in range(0, 24, 5):
    print(i)