关于python中生成唯一ID
PHP中文网
PHP中文网 2017-04-17 18:01:30
0
4
1134

python 中除了UUID可以生成唯一ID外,还有其他方法吗?这个UUID虽然可以做到,但太长了,有没有生成唯一ID比较短的方法?

PHP中文网
PHP中文网

认证0级讲师

reply all(4)
迷茫

Wouldn’t it be enough to automatically increase the player character ID and database ID?
You don’t need to set the ID yourself
Every time you add a new role, the server ID will be automatically +1
It will be unique in the same table

If it is multiple tables

Unique ID solution for sub-database and sub-table,
You can create a special ID table id_table, with only one column of ID and it is the primary key
Every time you insert a player role player_role record, first insert a record into the id_table and then
use LAST_INSERT_ID as player_role new id

黄舟

How can it be guaranteed to be unique if it’s too short?

刘奇

Maybe you can refer to it first:

shortuuid


Questions I answered: Python-QA

伊谢尔伦

A self-increasing int64 or something is fine

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!