摘要:        
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)
        
        
 
                    
                 浙公网安备 33010602011771号
浙公网安备 33010602011771号