当前位置:网站首页>[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
边栏推荐
- How to install govendor and open a project
- PostgreSQL里有只编译语句但不执行的方法吗?
- Does PgSQL have a useful graphical management tool?
- "Digital security" alert NFT's seven Scams
- 「数字安全」警惕 NFT的七大骗局
- Outlook 教程,如何在 Outlook 中搜索日历项?
- Go language series: where does go come from and where will go?
- Hcip notes 12 days
- Step by step introduction of sqlsugar based development framework (13) -- package the upload component based on elementplus, which is convenient for the project
- With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development
猜你喜欢

mindoc制作思维导图

四六级

Rainbond插件扩展:基于Mysql-Exporter监控Mysql

Random talk on generation diffusion model: DDPM = Bayesian + denoising

With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development

如何看一本书

生成扩散模型漫谈:DDPM = 贝叶斯 + 去噪

EasyUI modification and DataGrid dialog form control use

博后招募 | 西湖大学机器智能实验室招聘博士后/助理研究员/科研助理
Go语言系列:Go从哪里来,Go将去哪里?
随机推荐
博后招募 | 西湖大学机器智能实验室招聘博士后/助理研究员/科研助理
吴恩达机器学习编程作业无法暂停pause问题解决
Gtx1080ti fiber HDMI interference flash screen 1080ti flash screen solution
【硬件工程师】元器件选型都不会?
Is the online account opening of Founder futures reliable and safe?
Does PgSQL have a useful graphical management tool?
用秩讨论线性方程组的解/三个平面的位置关系
Chapter VI succession
EasyUI drop-down box, add and put on and off shelves of products
03.无重复字符的最长子串
8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇
Use huggingface to quickly load pre training models and datasets in moment pool cloud
Is it safe to open a securities account in Huatai VIP account
Briefly describe the implementation principle of redis cluster
博云容器云、DevOps平台斩获可信云“技术最佳实践奖”
[redis] redis installation
理财有保本产品吗?
Chapter 4: operators
我也是醉了,Eureka 延迟注册还有这个坑!
Boring post roast about work and life