摘要:        
常见概念 类和对象 class MyClass: num = 0 s = "" def __init__(self): # 构造函数 pass def print_info(self): print("num is: %s, str is: %s" %(self.num, self.s)) pass    阅读全文
posted @ 2023-07-21 01:15
yanghui01
阅读(12)
评论(0)
推荐(0)
        
            
        
        
摘要:        
Python中没有专门的queue类,而是把list当作队列来使用。 队列是一种先进先出的数据结构,主要的操作:入队,出队 queue1 = [] queue1.append(1) queue1.append(2) queue1.append(3) print(type(queue1)) # <cl    阅读全文
posted @ 2023-07-21 00:34
yanghui01
阅读(13)
评论(0)
推荐(0)
        
            
        
        
摘要:        
Python中没有没专门的stack类,而是可以把list当作栈来用 栈是一种先进后出的数据结构,主要的操作只有:入栈,出栈 stack1 = [] # 入栈 stack1.append(1) stack1.append(2) stack1.append(3) print(type(stack1))    阅读全文
posted @ 2023-07-21 00:34
yanghui01
阅读(10)
评论(0)
推荐(0)
        
            
        
        
摘要:        
常用操作 dict的key不能重复,不能为可变值;value可以重复 基本使用 dict1 = { "key1": 1, "key2": 2, "key3": 3, } print(type(dict1)) # <class 'dict'> print(type(dict1) == dict) #     阅读全文
posted @ 2023-07-21 00:33
yanghui01
阅读(7)
评论(0)
推荐(0)
        
            
        
        
摘要:        
常用操作 set的元素不能重复 set1 = {1, 2, 3} print(type(set1)) # <class 'set'> print(len(set1)) # 3 # 添加 set1.add(4) print(len(set1)) # 4 # 判断是否在集合中 print(1 in se    阅读全文
posted @ 2023-07-21 00:33
yanghui01
阅读(8)
评论(0)
推荐(0)
        
            
        
        
摘要:        
常用操作 列表的元素可以为空,也可以重复 基本使用 list1 = [1, 2, 3] print(type(list1)) # <class 'list'> print(type(list1) == list) # True print(isinstance(list1, list)) # Tru    阅读全文
posted @ 2023-07-21 00:22
yanghui01
阅读(10)
评论(0)
推荐(0)
        
            
        
        
摘要:        
常用操作 判断类型 print(type("abc")) # <class 'str'> print(type("abc") == str) # True print(isinstance("abc", str)) # True 遍历和长度 print(len("abc")) # 3 for c i    阅读全文
posted @ 2023-07-21 00:09
yanghui01
阅读(29)
评论(0)
推荐(0)
        
                    
                
浙公网安备 33010602011771号