- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 59字
- 2021-07-02 14:00:26
Sys.argv
The sys module is used to access command-line parameters. The len(sys.argv) function contains the number of arguments. To print all of the arguments, simply execute str(sys.argv). Let's have a look at an example:
01.py
import sys
print('Number of arguments:', len(sys.argv))
print('Argument list:', str(sys.argv))
Output:
Python3 01.py img
Number of arguments 2
Arguments list: ['01.py', 'img']
推薦閱讀
- Django開發從入門到實踐
- ASP.NET Core Essentials
- PostgreSQL技術內幕:事務處理深度探索
- PyTorch Artificial Intelligence Fundamentals
- Java程序設計與計算思維
- Windows Presentation Foundation Development Cookbook
- 基于Swift語言的iOS App 商業實戰教程
- Java Web程序設計任務教程
- Building Serverless Architectures
- Vue.js 3應用開發與核心源碼解析
- 軟件工程與UML案例解析(第三版)
- Learning Bootstrap 4(Second Edition)
- Java Hibernate Cookbook
- 美麗洞察力:從化妝品行業看顧客需求洞察
- JavaScript Mobile Application Development