In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use the click tool in Python, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand it.
First, get started quickly
The command line uses to dynamically pass values at run time to make the program do what it wants to do. Now there is a very simple program:
This program wants to determine how many times to print by the value of num. This time I want to print twice, and next time I want to print 10 times, so I need to manually modify the actual parameters of num.
If you use the command line, you can do dynamic assignment by entering the parameter 10 on the command line. Something like this:
You just need to modify the original code:
Note:-- times is consistent with the parameter times, otherwise an error will be reported.
After adding these two lines, you can use help information and parameters.
Run python loops.py-- help:
Run python loops.py-- times 3:
2. Required parameters for argument
If you do not pass a parameter, an error will be reported:
III. Setup
1. Install the library in the form of a script. After installation, you can run the library directly through the script command hello:
Name, script name, hello-- help runs the script
Version, version information, can be left unfilled.
Install_requires, required dependencies
Py_modules, required module
Entry_points, indicating the entry function of the script
Run hello yuz directly on the command line after configuration.
IV. Echo
If you use print, python2 and python3 are used differently, and echo is compatible.
5. Secho
Enter python loop.py yuz-- times 4:
Parameter description:
Fg, font color
Bg, background color
Underline, invalid under windows
Flink, invalid under windows
Bold, invalid under windows
Thank you for reading this article carefully. I hope the article "how to use click tools in Python" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.