摘要: def func(): print(123) return True def func2(): print('start') ret=func() print('ret:',ret) print('stop') return ret ret2=func2() print(ret2) #函数修改全局变 阅读全文
posted @ 2022-06-26 20:27 爱coding的果妈 阅读(28) 评论(0) 推荐(0)
摘要: 函数的作用1.增强代码的可读性2.降低代码的重复性 # def 函数的名字(): # 函数体,也叫代码块 # # def func():#函数的声明 # print(123) # func()#函数调用 lst=[1,2,3,4] # print(len(lst)) #自定义一个查看长度的函数 # 阅读全文
posted @ 2022-06-26 20:13 爱coding的果妈 阅读(26) 评论(0) 推荐(0)
摘要: #参数 # def len_func(s): #形参 # count=0 # for i in s: # count+=1 # return count # # str1=input('>>>') # str2=input('>>>') # ret1=len_func(str1) #实参 # ret 阅读全文
posted @ 2022-06-26 19:58 爱coding的果妈 阅读(205) 评论(0) 推荐(0)
摘要: #绝对路径:从磁盘根目录开始一直到文件名#相对路径:读取同一个文件夹下的文件,./文件名 ../返回上一层 #文件的读 #1、相对路径打开 f=open('userinfo') print(f.read()) f=open('./userinfo') #2、绝对路径打开 #在路径前+r #f=ope 阅读全文
posted @ 2022-06-26 19:57 爱coding的果妈 阅读(31) 评论(0) 推荐(0)
摘要: 冒泡排序基本思想:列表每相邻的两个数,如果前面的比后面的大,则交换这两个数目的:排除一个升序的列表一趟排序完后,无序区会减少一个数,有序区会增加一个数外层循环 确定走多少趟 列表长度-1内层循环 比较的次数 列表长度-1-当前第几趟 # lst=[0,34,-3,12,-5,66,333,2] # 阅读全文
posted @ 2022-06-24 21:45 爱coding的果妈 阅读(30) 评论(0) 推荐(0)
摘要: 字典 dict字典的特性就是查询快键值对 key value 字典的key是不可变的,value是可变的 dic={'key':'value',11:'12',True:[1,2],(1,):'你好',2.5:666,'22':{}} # print(dic) 字典的增加 1 dic1={'12': 阅读全文
posted @ 2022-06-24 21:43 爱coding的果妈 阅读(14) 评论(0) 推荐(0)
摘要: 定义:set集合是可变的无序序列,可添加、移除数据,没有索引,不能使用索引和切片集合的特性:1.集合中的对象具有唯一性 (去重)2.无序1、创建set集合 1 #set1={} #方法1 2 # print(type(set1)) 3 # 4 # set2=set() #方法2 5 # 6 # st 阅读全文
posted @ 2022-06-23 21:48 爱coding的果妈 阅读(46) 评论(0) 推荐(0)
摘要: 1、浅拷贝 1 l=['wind',123,True,['张三',123,'18',[12]],['李四',10086]] 2 l1=l.copy() 3 l2=l[:] 4 5 # print(l) 6 # print(l1) 7 # print(l2) 8 9 # l1.append('你好') 阅读全文
posted @ 2022-06-23 21:29 爱coding的果妈 阅读(23) 评论(0) 推荐(0)
摘要: 1、不可变类型(整型,浮点型,布尔值,字符串,元组) 1 name1='asdfg' 2 name2='asdfg' 3 print(id(name1)) 4 print(id(name2)) 5 #内存地址相同 6 7 print(name1==name2) 8 print(name1 is na 阅读全文
posted @ 2022-06-23 21:13 爱coding的果妈 阅读(36) 评论(0) 推荐(0)
摘要: 1、转大写/小写 1 str1='helloworld' 2 # str.upper()#字符串转大写 3 str2=str1.upper() 4 print(str2) 5 6 str2='HEELO' 7 # str.lower()#转小写 8 print(str2.lower()) 2、判断是 阅读全文
posted @ 2022-06-23 21:08 爱coding的果妈 阅读(140) 评论(0) 推荐(0)