随笔分类 -  Python

上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页
摘要:# 老虎 羊 喂养 import random # 父类 class Animal(): # 属性 def __init__(self,animal,w,call,food,room_num): self._animal=animal self._w=w self._call=call self._ 阅读全文
posted @ 2023-07-23 21:22 胖豆芽 阅读(29) 评论(0) 推荐(0)
摘要:# 羊 老虎 import random # 动物 class Animal(): def __init__(self,animal,weight,call,food,room_num): self._animal = animal self._weight = weight self._call 阅读全文
posted @ 2023-07-22 22:03 胖豆芽 阅读(15) 评论(0) 推荐(0)
摘要:# 求1到这个数阶乘 #1*2*3*4=24 def fac(num): result=1 for i in range(1,num+1): result *= i return result mul=fac(4) print(f'阶乘结果:{mul}') 阅读全文
posted @ 2023-07-21 16:34 胖豆芽 阅读(53) 评论(0) 推荐(0)
摘要:# 求10以内的质数 只能被自己和本身整除 # 2除以1是2 余数是0 # 2除以2是1 余数是0 # 4不是质数 因为4/2等于2 能被2整除 # 9不是质数 9%3 ==0 能被3整除 list_ob=[1,] for num in range(2,10): flag = True # 是质数吗 阅读全文
posted @ 2023-07-21 14:19 胖豆芽 阅读(97) 评论(0) 推荐(0)
摘要:import allure import pytest import os @allure.epic('微信')# Epic(史诗)是指一个大型的任务 @allure.feature('首页') #feature通常包括详细的功能描述、特定的输入和预期的输出 @allure.story('登录') 阅读全文
posted @ 2023-07-21 13:33 胖豆芽 阅读(16) 评论(0) 推荐(0)
摘要:import pytest @pytest.mark.parametrize('a,b,sum',[ # 参数化出来3组数据 (1,2,3), (2,3,5), (3,-19,-16) ]) def test_add(a,b,sum): assert a+b==sum # 如果 名称等于main 输 阅读全文
posted @ 2023-07-21 12:06 胖豆芽 阅读(14) 评论(0) 推荐(0)
摘要:import pytest @pytest.mark.parametrize('a,b,sum',[ # 参数化出来3组数据 (1,2,3), (2,3,5), (3,-19,-16) ]) def test_add(a,b,sum): assert a+b==sum # 如果 名称等于main 输 阅读全文
posted @ 2023-07-21 12:03 胖豆芽 阅读(22) 评论(0) 推荐(0)
摘要:#test_demo.pyimport allureimport pytestclass TestDemo: @allure.feature('比较功能') @allure.story('1等于1') def test_compare_numbers(self): expected = 1 actu 阅读全文
posted @ 2023-07-20 19:24 胖豆芽 阅读(112) 评论(0) 推荐(0)
摘要:在pycharm中下载 allure-pytest包 解决办法: pip install allure-pytest 坑: 解释报错原因:使用的命令不对 pip install allure 报错 没有这个allure包 阅读全文
posted @ 2023-07-20 18:02 胖豆芽 阅读(430) 评论(0) 推荐(0)
摘要:dict10={'a':'aa','b':'bb','c':'cc'} new_dict={'a':'a','b':'b'} dict10.update(new_dict)# updata 可以新增或者修改字典 print(dict10) ''' {'a': 'a', 'b': 'b', 'c': 阅读全文
posted @ 2023-07-20 12:27 胖豆芽 阅读(22) 评论(0) 推荐(0)
摘要:import pytest class Test1: def test1(self): assert 1 == 1 assert 2 + 2 == 4 assert 3 + 3 == 6 if __name__=='__main__': pytest.main([__file__]) ''' tes 阅读全文
posted @ 2023-07-19 21:55 胖豆芽 阅读(31) 评论(0) 推荐(0)
摘要:# 导入随机数包 import random # 第一个类 动物类 class Animal: # 定义属性 def __init__(self,animal,weight,call,food): self._animal=animal self._weight=weight self._call= 阅读全文
posted @ 2023-07-19 18:35 胖豆芽 阅读(19) 评论(0) 推荐(0)
摘要:import random # 动物类 class Animal: def __init__(self, animal_type, weight, cries, food): self._animal_type = animal_type self._weight = weight self._cr 阅读全文
posted @ 2023-07-18 22:11 胖豆芽 阅读(13) 评论(0) 推荐(0)
摘要:import random# 动物类class Animal: def __init__(self, animal_type, weight, cries, food): self._animal_type = animal_type self._weight = weight self._crie 阅读全文
posted @ 2023-07-18 17:59 胖豆芽 阅读(16) 评论(0) 推荐(0)
摘要:# 目标获取10个房间里的动物 和体重 import random class Room: def __init__(self,roomnum,animal_type): # 房间号 self._roomnum=roomnum # 动物 self._animal_type=animal_type # 阅读全文
posted @ 2023-07-17 21:48 胖豆芽 阅读(42) 评论(0) 推荐(0)
摘要:from loguru import logger logger.debug("异常") logger.info("异常") logger.warning("异常") logger.error("异常") logger.critical("异常") # 对日志做配置 放在指定的文件夹 当超过200K 阅读全文
posted @ 2023-07-17 21:47 胖豆芽 阅读(43) 评论(0) 推荐(0)
摘要:try: # num=int(input("请输入数字:")) # print(1/num) age= int(input("请输入年龄,不要小于18岁:")) if age < 18: # 非python的异常,业务逻辑上的异常,主动异常 raise raise NameError('异常,年纪小 阅读全文
posted @ 2023-07-17 19:25 胖豆芽 阅读(24) 评论(0) 推荐(0)
摘要:# 单例 司机只有一个 class Driver: _self=None _name = "Driver Jack" # 司机的姓名 _num = 0 # 司机的业绩 初始值是0 def __new__(cls, *args, **kwargs): if cls._self is None: cls 阅读全文
posted @ 2023-07-17 17:40 胖豆芽 阅读(13) 评论(0) 推荐(0)
摘要:# 定义一个不重复的列表 import random list= [] count= 0 # 成功放入的次数 while count<5: num= random.randint(1,10) if num not in list: list.append(num) count+=1 # 成功后计数一 阅读全文
posted @ 2023-07-17 17:12 胖豆芽 阅读(15) 评论(0) 推荐(0)
摘要:# 售票员卖票 class Driver: _self=None _name= 'Driver_Jack'# 售票员的名字 _num= 0 # 售票员的业绩 def __new__(cls, *args, **kwargs): if cls._self is None :# 如果售票员这个类是空 c 阅读全文
posted @ 2023-07-16 21:04 胖豆芽 阅读(12) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页