Repositories
Help
py.lib.aw_web_tools
Commits
Files
Yohn Y.
2024-02-25
Parent:
06f00ec09030
1:cb0dd8d1c0e9
Go to Latest
py.lib.aw_web_tools/src/aw_web_tools/misc_tools.py
Added tag 0.202402.1 for changeset 06f00ec09030
Download raw file
View source
Diff to previous
Annotate
History
Loading...
1
# coding: utf-8
2
from
typing
import
Union
,
List
,
Tuple
3
4
5
def
dict_filter
(
data
:
dict
,
need_keys
:
Union
[
List
[
str
],
Tuple
[
str
]])
->
dict
:
6
"""\
7
Создать новый словарь на основе существующего, добавив в него только нужные ключи
8
"""
9
return
dict
((
key
,
val
)
for
key
,
val
in
data
.
items
()
if
key
in
need_keys
)