CI脚本的python基础

基础python语法

getopt.getopt(args, shortopts, longopts=[])

args指的是当前脚本接收的参数,它是一个列表,可以通过sys.argv获得
shortopts 是短参数  啥是短参数啊?  类似于 这样:python test.py -h # 输出帮助信息
longopts 是长参数  啥是长参数啊?  类似于 这样:python test.py -help # 输出帮助信息

import getopt
import sys
 
arg = getopt.getopt(sys.argv[1:],'-h-f:-v',['help'])
print(arg)

为啥传入sys.argv[1:]?因为sys.argv里的argv[0]是当前脚本的文件名,不需要它去参与,要不然你的选项和选项值无法匹配,问题多多。
我定义了’-h-f:-v’ 大家发现没有,在-f后面多了一个":"
这个":"代表了当前参数后面可以跟着其他值。
opts与args:
opts 为分析出的格式信息。args 为不属于格式信息的剩余的命令行参数。
opts 是一个两元组的列表。每个元素为:( 选项串, 附加参数) 。如果没有附加参数则为空串’’

requests.request

https://blog.csdn.net/u011608531/article/details/109356728

json.loads()

https://blog.csdn.net/daerzei/article/details/100598901

os.popen

https://blog.csdn.net/xc_zhou/article/details/96445422

split的用法

https://blog.csdn.net/JohinieLi/article/details/76196882

os.path.exist

https://blog.csdn.net/qq_43426078/article/details/123429843

shutil.rmtree以及shutil家族

https://blog.csdn.net/jiandanjinxin/article/details/71489080
https://blog.csdn.net/qq_38640439/article/details/81410116

shutil.make_archive

https://blog.csdn.net/Leeeey/article/details/90042111

time.strftime计算

https://www.runoob.com/python/att-time-strftime.html

Python zfill(width)方法

指定长度的字符串,原字符串右对齐,前面填充0

python的exit退出

https://gairuo.com/p/python-quit-exit

相关推荐

  1. CI脚本python基础

    2024-07-09 23:30:04       23 阅读
  2. 编写CI/CD自动化部署脚本

    2024-07-09 23:30:04       54 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 23:30:04       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 23:30:04       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 23:30:04       58 阅读
  4. Python语言-面向对象

    2024-07-09 23:30:04       69 阅读

热门阅读

  1. uni-app + vue3项目引入unocss

    2024-07-09 23:30:04       18 阅读
  2. 深度学习 - 模型的保存与部署方式汇总

    2024-07-09 23:30:04       16 阅读
  3. C++ 算法——二分查找

    2024-07-09 23:30:04       19 阅读
  4. Spring事务

    2024-07-09 23:30:04       19 阅读
  5. c# 基础习题答案 20240709

    2024-07-09 23:30:04       18 阅读
  6. MAC下的PDM工具

    2024-07-09 23:30:04       22 阅读
  7. Dubbo源码解析-过滤器Filter

    2024-07-09 23:30:04       22 阅读
  8. 开源大模型对比

    2024-07-09 23:30:04       27 阅读
  9. Mongodb索引的删除

    2024-07-09 23:30:04       20 阅读
  10. ubuntu minio在线安装、开机启动

    2024-07-09 23:30:04       21 阅读
  11. 正则表达式-使用笔记

    2024-07-09 23:30:04       27 阅读