字典是否具有密钥长度限制? [英] Do Dictionaries have a key length limit?

查看:353
本文介绍了字典是否具有密钥长度限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道Python是否对字典键的长度有限制。

I was wondering if Python had a limit on the length of a dictionary key.

为了澄清,我不是在说钥匙的数量,而是每个密钥的长度。我将根据动态值(验证后)建立我的字典,但我不知道在这种情况下是否应该考虑长度。

For clarification, I'm not talking about the number of keys, but the length of each individual key. I'm going to be building my dictionaries based on dynamic values (after validation), but I'm not sure if I should be taking length into account in this case.

推荐答案

关于字典键没有这样的限制。由于python在数值类型上也具有任意的精度,所以您将遇到的唯一限制(字符串或其他)是可用内存的限制。您可以在另一篇文章此处中查看python 2中的最大字符串长度。

There is no such limit in place regarding dictionary keys. Since python also has arbitrary precision on numeric types, the only limit you will encounter, string or otherwise, is that of available memory. You can see another post here for a discussion on maximum string length in python 2.

这篇关于字典是否具有密钥长度限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆