擅长:python、mysql、java
<h2>正确答案</h2>
<p>正如<a href="https://stackoverflow.com/questions/4267475/generating-8-character-only-uuids">here</a>所回答的,这个问题的正确答案是,<strong>不可能生成8个字符的uuid,因为uuid定义为16个字节。</strong></p>
<p>uuid的标准在<a href="https://www.rfc-editor.org/rfc/rfc4122" rel="nofollow noreferrer">RFC 4221</a>中指定。在<a href="https://www.rfc-editor.org/rfc/rfc4122#section-4.1" rel="nofollow noreferrer">format section</a>中,第一个词是:</p>
<blockquote>
<p>The UUID format is 16 octets</p>
</blockquote>
<p>谢谢你<a href="https://stackoverflow.com/users/7016115/shudipta-sharma">shudipta-sharma</a>注意到我的原始答案不会产生一个通用的唯一id</p>
<h2>旧(不正确)答案</h2>
<p><s>您可以只取前八个字符。</s></p>
<s>
```Python
id1=str(uuid.uuid1())[:8]
```
</s>
<p><s>不保证它们都是唯一的。</s></p>