摘要: return 一个函数的值 1 def add(a1, a2): 2 return a1+a2 3 4 def subtract(a1, a2): 5 return a1-a2 6 7 def multiply(a1, a2): 8 return a1*a2 9 10 def devide(a1, 阅读全文
posted @ 2021-01-22 23:54 子非鱼-DJ 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 1 def print_a_line_no_huanhang(line_count,f): 2 print(line_count, f.readline(),end="") 3 4 f3 = open("study.txt") 5 6 f3.seek(0) 7 8 line_count = 1 9 阅读全文
posted @ 2021-01-22 23:42 子非鱼-DJ 阅读(53) 评论(0) 推荐(0) 编辑
摘要: def print_txt(f): txt_data = f.read() print(txt_data) def rewind(f): f.seek(0) def print_a_line(line_count,f): print(line_count, f.readline()) f1 = op 阅读全文
posted @ 2021-01-22 23:39 子非鱼-DJ 阅读(135) 评论(0) 推荐(0) 编辑
摘要: file.seek()方法标准格式是:seek(offset,whence=0)offset:开始的偏移量,也就是代表需要移动偏移的字节数whence:给offset参数一个定义,表示要从哪个位置开始偏移;0代表从文件开头开始算起,1代表从当前位置开始算起,2代表从文件末尾算起。默认为0whence 阅读全文
posted @ 2021-01-22 23:02 子非鱼-DJ 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 习题17 函数 学习参考书籍《“笨方法”学python3》美 Zed A. Shaw著 王巍巍译 #function def print_two(*args): args1,args2=args print(f"args1:{args1},args2:{args2}") def print_two_ 阅读全文
posted @ 2021-01-22 22:59 子非鱼-DJ 阅读(103) 评论(0) 推荐(0) 编辑