How to make unique short URL with Python?

后端 未结 12 1281
渐次进展
渐次进展 2020-12-02 07:02

How can I make unique URL in Python a la http://imgur.com/gM19g or http://tumblr.com/xzh3bi25y When using uuid from python I get a very large one. I want something shorter f

12条回答
  •  一个人的身影
    2020-12-02 08:00

    This module will do what you want, guaranteeing that the string is globally unique (it is a UUID):

    http://pypi.python.org/pypi/shortuuid/0.1

    If you need something shorter, you should be able to truncate it to the desired length and still get something that will reasonably probably avoid clashes.

提交回复
热议问题