上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 65 下一页
摘要: # 自动生成 1 2 3 l=list(range(1,4)) print(l) #求 1*1 2*2 3*3 l2=[] for x in range(1,4): l2.append(x*x) print(l2) # 简化 print([x * x for x in range(1, 4)]) # 阅读全文
posted @ 2023-07-08 20:40 胖豆芽 阅读(9) 评论(0) 推荐(0) 编辑
摘要: # 字符串的for 循环 str1 = 'abc' for i in str1: print(i) ''' a b c ''' # 字典的for 循环 dict1 = {'name':'fqs','age':18,'address':'beijing'} for key in dict1: prin 阅读全文
posted @ 2023-07-08 19:54 胖豆芽 阅读(5) 评论(0) 推荐(0) 编辑
摘要: str1='abcd' stat省去0_num_end = str1[:2] print(stat省去0_num_end) stat_num_end省去結尾的下标 = str1[2:] print(stat_num_end省去結尾的下标) ''' ab cd ''' def trim(s): if 阅读全文
posted @ 2023-07-08 19:47 胖豆芽 阅读(21) 评论(0) 推荐(0) 编辑
摘要: def hanoi(n, source, target, auxiliary): if n > 0: # 将 n-1 个盘子从源柱子移动到辅助柱子 hanoi(n-1, source, auxiliary, target) # 将最大的盘子从源柱子移动到目标柱子 print("Move disk", 阅读全文
posted @ 2023-07-08 17:25 胖豆芽 阅读(5) 评论(0) 推荐(0) 编辑
摘要: from typing import Union my_list:list[Union[str,int]]=[1,2,"it",'it'] my_doc:dict[str,Union[str,int]]={'name':'周',"age":31} print(my_list,my_doc) 阅读全文
posted @ 2023-07-07 18:25 胖豆芽 阅读(3) 评论(0) 推荐(0) 编辑
摘要: class Phone: producer="IT" def call_by_5g(self): print("父类使用5g网络进行通话") # 定义子类 class MyPhone(Phone): producer = 'TO' def call_by_5g(self): print("自己的手机 阅读全文
posted @ 2023-07-06 21:50 胖豆芽 阅读(3) 评论(0) 推荐(0) 编辑
摘要: class Phone: IMEI=2020001 producer="apple" def call_by_4g(self): print("4g通话") class NFCReader: nfc_type="第五代" producer="apple" def read_card(self): p 阅读全文
posted @ 2023-07-06 21:18 胖豆芽 阅读(1) 评论(0) 推荐(0) 编辑
摘要: class Phone: IMEI=2020001 producer="apple" def call_by_4g(self): print("4g通话") class Phone2023(Phone): face_id="2233" def call_by_5g(self): print(f"20 阅读全文
posted @ 2023-07-06 20:55 胖豆芽 阅读(2) 评论(0) 推荐(0) 编辑
摘要: class Phone: __current_voltage=3 #当前手机运行的电压 def __keep_single_core(self):#让手机单核运行的方法 print("让CPU以单核模式运行") def call_by_5g(self):#定义一个共有的方法 调用私有的方法和属性 i 阅读全文
posted @ 2023-07-06 20:01 胖豆芽 阅读(9) 评论(0) 推荐(0) 编辑
摘要: class Student:#创建一个类 name=None age=None tel=None def __init__(self,name,age,tel):#构造函数 self.name=name self.age=age self.tel=tel print("student类创建了一个对象 阅读全文
posted @ 2023-07-06 17:07 胖豆芽 阅读(4) 评论(0) 推荐(0) 编辑
上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 65 下一页