Double陈

2021年3月30日

三元、列表等其他生成式

摘要: # # 三元表达式# def func(x,y):# if x>y:# return x# else:# return y## # 用三元表达式# x=1# y=2# res=x if x>y else y# print(res)## 列表生成式# l = ["name_zhu", "age_zhu 阅读全文

posted @ 2021-03-30 17:15 Double陈 阅读(36) 评论(0) 推荐(0) 编辑

迭代器与生成器的使用

摘要: # 争对不能索引取值的对象# d={"name":"chenhao","age":18,"both":2018}# # 第一步先把可迭代对象转换成迭代器# res=iter(d)# while True: # 第二部循环取值# try:# print(next(res))# except StopI 阅读全文

posted @ 2021-03-30 17:13 Double陈 阅读(40) 评论(0) 推荐(0) 编辑

2021年3月29日

函数的装饰器

摘要: # 案例一错误改变了源代码# import time# def func(x,y):# start=time.time()# time.sleep(3)# print("index %s %s" %(x,y))# stop=time.time()# print(stop-start)## func( 阅读全文

posted @ 2021-03-29 15:37 Double陈 阅读(28) 评论(0) 推荐(0) 编辑

文件基本操作seek指针移动

摘要: # f.seek的转账应用用户输入充值信息的同时有文件能检测是否有短信录入#追加的文本内容with open("a.txt",mode="at",encoding="utf-8") as f: f.write("2021.3.24账户充值100元")# 查看文件的内容import timewith 阅读全文

posted @ 2021-03-29 15:33 Double陈 阅读(79) 评论(0) 推荐(0) 编辑

文件的基本操作

摘要: # 文件拷贝工具name=input("文件的路径")pwd=input("文件的路径")with open(r"{}".format(name),mode="rb") as x: with open(r"{}".format(pwd),mode="wb") as y: res=x.read() y 阅读全文

posted @ 2021-03-29 15:32 Double陈 阅读(39) 评论(0) 推荐(0) 编辑

基本数据类型字符串类型

摘要: # # 写代码,有如下变量,请按照要求实现每个功能 (共6分,每小题各0.5分)name = "**aleX*"# # 1) 移除 name 变量对应的值两边的空格,并输出处理结果print(name.strip("*"))# # 2) 判断 name 变量对应的值是否以 "al" 开头,并输出结果 阅读全文

posted @ 2021-03-29 15:30 Double陈 阅读(57) 评论(0) 推荐(0) 编辑

基本数据类型列表

摘要: #以下三种是往列表里增加值#l=[2222,3333,"egon",{"name":"egon","age":18}]l.append(999)print(l) #追加值l.insert(2,[2,"good"]) #先索引的位置 再内容print(l) #插入值 代表索引的位置 逗号后面的代表索引 阅读全文

posted @ 2021-03-29 15:29 Double陈 阅读(45) 评论(0) 推荐(0) 编辑

基本数据类型元组和字典还有集合的使用

摘要: # 队列与堆栈# l=[]# l.append("first")# l.append("sconed")# l.append("third")# print(l)# print(l.pop(2))# print(l.pop(1))# print(l.pop(0))# 元组数据类型# 元组 (不可变的 阅读全文

posted @ 2021-03-29 15:28 Double陈 阅读(49) 评论(0) 推荐(0) 编辑

2021年3月18日

day5 for循环和字符串数据类型的基本使用

摘要: for循环 for i in range(10): 缩进的代码块 问题 打印九九乘法表 for i in range(1,10): for j in range(1,i+1): print('%s*%s=%s' %(i,j,i*j),end=' ') print() 一.可变类型和不可变类型可变类型 阅读全文

posted @ 2021-03-18 08:52 Double陈 阅读(50) 评论(0) 推荐(0) 编辑

day4 if判断和while循环的基本操作和使用

摘要: if判断使用 if 条件1: 缩进的代码块 elif 条件2: 缩进的代码块 elif 条件3: 缩进的代码块 ...... else: 缩进的代码块 基本练习题 ''' egon --> 超级管理员 tom --> 普通管理员 jack,rain --> 业务主管 其他 --> 普通用户 ''' 阅读全文

posted @ 2021-03-18 08:44 Double陈 阅读(190) 评论(0) 推荐(0) 编辑

导航