我有一个配置信息的字典:
my_conf = {
'version': 1,
'info': {
'conf_one': 2.5,
'conf_two': 'foo',
'conf_three': False,
'optional_conf': 'bar'
}
}
Run Code Online (Sandbox Code Playgroud)
我想检查字典是否遵循我需要的结构.
我正在寻找这样的东西:
conf_structure = {
'version': int,
'info': {
'conf_one': float,
'conf_two': str,
'conf_three': bool
}
}
is_ok = check_structure(conf_structure, my_conf)
Run Code Online (Sandbox Code Playgroud)
是否有任何解决方案可以解决此问题或任何可以使实施check_structure更容易的库?
有什么简单的方法可以在带有参数的VS Code中运行python文件吗?
我知道我可以launch.json使用args关键字在文件中添加自定义配置。但是,launch.json仅仅因为我想使用不同的参数,每次修改都是很烦人的。
我读过关于新的Python"关键字" async和await.但它们既不是关键字,也不是命名空间中的保留.
>>> import keyword
>>> keyword.iskeyword("async")
False
>>> async
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'async' is not defined
Run Code Online (Sandbox Code Playgroud)
在我希望True和SyntaxError关键字的示例中.
那么,asyncPython 到底是什么?这个怎么运作?
python ×3
async-await ×1
asynchronous ×1
config ×1
debugging ×1
dictionary ×1
keyword ×1
python-3.x ×1
schema ×1
validation ×1