我正在构建一个小型 API。现在,我正在针对需要稍后发送到函数的可选参数使用此变通方法解决方案。
if 'A' in request.args:
A = request.args['A']
else:
A = 0
Run Code Online (Sandbox Code Playgroud)
但我觉得必须有一些精确的东西。这似乎有点不专业。就像我在 argparse 工作时一样
parser.add_argument('--A', type=int, required=False')
Run Code Online (Sandbox Code Playgroud)
请问,是否可以稍微缩短第一部分并使用它们的一些功能?谢谢
我已经完成了这个小包,我想在我的社区中分发。它现在在 test.pypi 上,当我想尝试安装它时,它给出了找不到依赖项的错误。
设置文件
...
install_requires=[
'defcon>=0.6.0',
'fonttools>=3.31.0'
]
...
Run Code Online (Sandbox Code Playgroud)
抛出这个错误
ERROR: Could not find a version that satisfies the requirement defcon>=0.6.0 (from sameWidther==0.6) (from versions: none)
ERROR: No matching distribution found for defcon>=0.6.0 (from sameWidther==0.6)
Run Code Online (Sandbox Code Playgroud)
但是当我手动安装时,它可以工作
pip install 'fonttools>=3.6.0'
pip install 'defcon>=0.6.0'
Run Code Online (Sandbox Code Playgroud)