摘要: 1 #复制文件,并且复制后的文件名为xxx[复件].py 2 #列 test.py 复制后 test[复件].py 3 4 5 #获取文件名 6 old_file = input('输入要复制的文件名:') 7 8 #读取文件 9 ofile = open(old_file,'r') 10 cfile = ofile.read() 11 12... 阅读全文
posted @ 2018-04-18 17:27 Smalllv 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1 a = [100] 2 3 def test(num): 4 #num+=num #如果num是可变类型,修改它。如果是不可变类型,重新指向一 个内存地址并赋值。 5 6 num = num+num # 直接重新指向一个内存地址,赋予num。 num+=num和num = nu ... 阅读全文
posted @ 2018-04-18 13:01 Smalllv 阅读(765) 评论(0) 推荐(0) 编辑
摘要: 1 a = 3 2 b = 4 3 4 #a,b交换让a = 4,b = 3. 5 6 #第一种 7 8 #c = 0 9 #c = a 10 #a = b 11 #b = c 12 13 14 15 #第二种 16 #a = a+b 17 #b = a-b 18 #a = a-b 19 20 21 #第三种 22 ... 阅读全文
posted @ 2018-04-18 12:39 Smalllv 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 2 3 def niming(a,b,func): 4 5 result = func(a,b) 6 return result 7 find = input('请输入一个匿函数:') 8 find = eval(find) #eval 相当与把字符串的引号去掉,使得find输入的匿名函数执 #行 9 10 num = ni... 阅读全文
posted @ 2018-04-18 12:05 Smalllv 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 3 def niming(a,b,func): 4 5 result = func(a,b) 6 return result 7 8 num = niming(11,12,lambda x,y:x+y) 9 print(num) ~ 阅读全文
posted @ 2018-04-18 11:46 Smalllv 阅读(149) 评论(0) 推荐(0) 编辑