CI脚本的python基础

CI脚本的python基础

基础python语法

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

args指的是当前脚本接收的参数,它是一个列表,可以通过sys.argv获得

shortopts 是短参数  啥是短参数啊?  类似于 这样:python test.py -h # 输出帮助信息

longopts 是长参数  啥是长参数啊?  类似于 这样:python test.py -help # 输出帮助信息

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

为啥传入sys.argv1:?因为sys.argv里的argv0是当前脚本的文件名,不需要它去参与,要不然你的选项和选项值无法匹配,问题多多。

我定义了'-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

相关推荐
deepseek2313 分钟前
Python日志拖慢请求?QueueHandler排队、丢失与退出实测
python·性能优化·logging·后端开发·queuehandler
用户912940468484219 分钟前
Codex 从零到能交付(05):第一次改代码:生成一个文件清单脚本
python
Dmz丶20 分钟前
前端转 AI 100 天 Day 38:Token 管理与成本优化——别让 API 账单爆炸
python
VimorphTech41 分钟前
每批开 4 个线程,为什么限制不住 TTS 的总并发?
java·spring boot·spring
Pniubi1 小时前
Java为什么要分堆和栈
java·开发语言
杨凯凡1 小时前
Spring Boot 缓存一致性怎么保证?@Cacheable、@CacheEvict 与事务提交时机实战
java·spring boot·spring cache·后端开发·缓存一致性
用户298698530141 小时前
Python 自动化处理 Word 页眉页脚的几种典型场景
后端·python·api
終不似少年遊*1 小时前
【安全业务Agent】从场景到编排
python·react.js·ai·langchain·agent·安全架构·工作流
AKA__Zas2 小时前
接口自动化测试(1.0 初认识
python·ci/cd·学习方法
Rain的Java大神之路2 小时前
国家数据集团校招、社招都开了:总部雄安,这些技术岗值得认真看看
java·后端·面试