当前位置 : 主页 > 编程语言 > python >

python编程模板

来源:互联网 收集:自由互联 发布时间:2022-06-30
#!/usr/bin/env python # -*- coding:utf-8 -*- # @FileName :脚本名 # @Time :2021/12/17 # @Author :运维@小兵 # @Function :脚本介绍 # @Excute :python 脚本名 参数 ######################导入模块###################### from date
#!/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)


上一篇:python处理GMT时间
下一篇:没有了
网友评论