DictDefaultNone. Get data from nested lists and dictionaries use simple syntax(eg.: dict1["k1"]["k2"][0]["k"]), if can‘t return None, no raise error
Project description
DictDefaultNone
Get data from nested lists and dictionaries use Simple syntax, if can‘t return None, no raise IndexError or KeyError 用简单的python语法快速获取嵌套列表或者字典里的数据,如果没取到则返回空,而不是抛出IndexError或者KeyError
eg.: dict1["k1"]["k2"][0]["k"]
from ddn import DDN
data = {
"data": [
{
"key1": "123",
"key2": {
"kkey1": {
"kkkey1": "1234",
"kkkey2": 12345
}
}
},
{
"key1": "'1234'",
"key3": {
"kkey1": {
"kkkey1": "1234",
"kkkey2": True
}
}
}
]
}
d = DDN(data)
if d['data'][1]["key3"]["kkey1"]['kkkey1']:
print('ok')
if d['data'][88]["user"]["username"]['firstname']:
print('no')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ddn-1.0.0.tar.gz
(14.9 kB
view details)
Built Distribution
ddn-1.0.0-py3-none-any.whl
(14.8 kB
view details)
File details
Details for the file ddn-1.0.0.tar.gz
.
File metadata
- Download URL: ddn-1.0.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d1fa28f0a37dcc5b55568b19c6b8a05315ce96b65644165a6478695884ef508 |
|
MD5 | 6b42ba15f94fa7604a4b3f9c8e9f0cac |
|
BLAKE2b-256 | 26c65b5c9d0529aa9d9c2eb166b82bcf15912bb2374c716a192804b8c23a1433 |
File details
Details for the file ddn-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: ddn-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a86c7b5f13a9246615114728881c3da27904aeebae5fe7415f21d12eeb46f23b |
|
MD5 | b40d8ba7019012dd74d49674e16f1edd |
|
BLAKE2b-256 | 75be9b2cf4a40d6254e5b91da7ebac3d96ce599796821c89b9520d51942a9bcd |