0
点赞
收藏
分享

微信扫一扫

python编程模板

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName :脚本名
# @Time :2021/12/17
# @Author :运维@小兵
# @Function :脚本介绍
# @Excute :python 脚本名 参数

######################导入模块######################
from datetime import datetime
import sys,os

######################定义变量######################
workdir= os.path.dirname(os.path.abspath(__file__)) # 获取当前脚本绝对路径

"""
This is a Check Env

:param param1: this is a first param
:param param2: this is a second param

:returns: this is a description of what is returned

:raises keyError: raises an exception
"""
def check_env():
ex = Exception('Invalid Param!!! eg:python %s 保存过期证书信息的文件 证书文件 几个月后 证书过期时间' % sys.argv[0]) #自定义异常
if len(sys.argv) != 5:
raise ex

if __name__ == '__main__':
try:
check_env()
except Exception as e:
print('ERROR:%s' % e)


举报

相关推荐

0 条评论