接口自动化之学习笔记基于python语言(一)

我希望能通过这个学习和笔记使自己成长,也希望通过此学习笔记给正在学习的朋友一些帮助!

此为我开此博客的初中。

先学习一下xlrd库的使用;

class RequestInterface(object):
    def __new_param(self,param):
        try:
            if isinstance(param,str) and param.startswith('{'):
                new_param=eval(param)
            elif param==None:
                new_param=''
            else:
                new_param=param
        except Exception as error:
            new_param=''
            logging.basicConfig(filename = config.src_path + '/log/syserror.log',level = logging.DEBUG,format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s')
            logger = logging.getLogger(__name__)
            logger.exception(error)
        return new_param

 

解析:定义一个类,方法中两个下划线“__new_param”中的“__”的意思是类中的私有方法,其他类不可调用。

isinstance判断类,此代码中判断param是否为字符型,.startswith是不是以(‘{’)开头,eval类型转换,打印日志

 

 

 

 

你可能感兴趣的:(接口自动化之学习笔记基于python语言(一))