上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 80 下一页
摘要: 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 胖豆芽 阅读(36) 评论(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 胖豆芽 阅读(26) 评论(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 胖豆芽 阅读(9) 评论(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 胖豆芽 阅读(17) 评论(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 胖豆芽 阅读(8) 评论(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 胖豆芽 阅读(11) 评论(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 胖豆芽 阅读(22) 评论(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 胖豆芽 阅读(12) 评论(0) 推荐(0)
摘要: class student: name=None def say_hi(self,msg): print(f"大家好呀,我是:{self.name},{msg}") stu=student() stu.name='fqs' stu.say_hi("我想死大家了") #设计一个闹钟 class Clo 阅读全文
posted @ 2023-07-06 16:14 胖豆芽 阅读(7) 评论(0) 推荐(0)
摘要: student_info={ 15:{'jack','rose',}, 18:{'jj'}, 35:{'a','b','c','d'}, } age_counts = {}# 定义一个字典 key=age value=name的长度 for age in student_info: count = 阅读全文
posted @ 2023-07-05 21:51 胖豆芽 阅读(27) 评论(0) 推荐(0)
上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 80 下一页