当前位置:网站首页>[vscode] support argparser/ accept command line parameters
[vscode] support argparser/ accept command line parameters
2022-07-25 17:27:00 【Beauty of algorithm and programming】
problem
Python Of argparser It's very powerful , It is widely used in complex engineering projects .vscode It's the most popular IDE development environment , So how to be in vscode Middle configuration argparser Well ?
Method
(1) modify .vscode Of launch.json file
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"args": [
"--name","Alice",
"--age", "18",
],
}
]
}
(2) argparser Chinese programming
from argparse import ArgumentParser
parser = ArgumentParser(description='test argparser')
parser.add_argument('--name', type=str, default='name', help='please specify your name in cmd')
parser.add_argument('--age', type=int, default=18, help='please specify your age in cmd')
arg = parser.parse_args()
print(arg.name, arg.age)
(3) Output results
Alice 18
边栏推荐
- I2C通信——时序图
- Summary of 80 domestic database operation documents (including tidb, Damon, opengauss, etc.)
- 博后招募 | 西湖大学机器智能实验室招聘博士后/助理研究员/科研助理
- 多租户软件开发架构
- How to delete Microsoft Pinyin input method in win10
- From digitalization to intelligent operation and maintenance: what are the values and challenges?
- Briefly describe the implementation principle of redis cluster
- [target detection] tph-yolov5: UAV target detection based on Transformer's improved yolov5
- 博云容器云、DevOps平台斩获可信云“技术最佳实践奖”
- Random talk on generation diffusion model: DDPM = Bayesian + denoising
猜你喜欢
随机推荐
Rainbow plug-in extension: monitor MySQL based on MySQL exporter
第五章:流程控制
[redis] redis installation
jenkins的Role-based Authorization Strategy安装配置
【硬件工程师】元器件选型都不会?
Mindoc makes mind map
走马卒
With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development
04. Find the median of two positive arrays
【PHP伪协议】源码读取、文件读写、任意php命令执行
理财有保本产品吗?
电子产品“使用”和“放置”哪个寿命更长??
Outlook 教程,如何在 Outlook 中搜索日历项?
多项式相加
动态规划题目记录
Postdoctoral recruitment | West Lake University Machine Intelligence Laboratory recruitment postdoctoral / Assistant Researcher / scientific research assistant
一篇文章了解超声波加湿器
一百个用户眼中,就有一百个QQ
win10设备管理认不到GTX1080Ti 显示设备的解决办法
The gas is exhausted! After 23 years of operation, the former "largest e-commerce website in China" has become yellow...









