python引入雪花算法模块

1.pip安装

pip3 install pysnowflake

2.启动服务

nohup snowflake_start_server --address=127.0.0.1 --port=8910 --dc=1 --worker=1 --log_file_prefix=/tmp/pysnowflask.log>/dev/null &

3.调用雪花算法

import snowflake.client
def get_snowflake_uuid():
    guid = snowflake.client.get_guid()
    return guid
get_snowflake_uuid()
posted @ 2020-10-20 19:00  碎了的冰  阅读(1779)  评论(0编辑  收藏  举报