02 2019 档案

leetcode习题练习
摘要:day001 两数之和 #!user/bin/env python # -*- coding:utf-8 -*- #方法1 def Sum(nbs,tgt): len_nums = len(nbs) for i in range(len_nums): for j in range(i+1,len_n 阅读全文

posted @ 2019-02-28 01:07 yukun093 阅读(154) 评论(0) 推荐(0)

文件处理,三元操作符,seek()函数,迭代函数和列表解析,reduce函数
摘要:1.文件读取方类型 r,r+,w,x,a, r,读文件 w,写文件,文件内容全部删除,并将新内容从第一行开始赋值 x,写文件,只有文件不存在,可写,文件存在,报错 a,在文件莫问追加信息 r+,w+,x+,a+ 文件均为可读可写 rb,wb,xb,ab rb,b的方式不能指定编码,读出原生二进制码, 阅读全文

posted @ 2019-02-26 00:29 yukun093 阅读(514) 评论(0) 推荐(0)

zip()函数,max()和min(),built-in function,import模块,read(),readlines(),write(),writelines(),with..as..文件处理方式
摘要:zip()函数:将可迭代对象作为参数,将对象中的对应元素打包成一个个元组。 #map()普通的输出例子 print(list(zip(('a','n','c'),(1,2,3)))) print(list(zip(('a','n','c'),(1,2,3,4)))) print(list(zip(( 阅读全文

posted @ 2019-02-22 10:41 yukun093 阅读(361) 评论(0) 推荐(0)

scoping作用域,anonymous function匿名函数,内置函数
摘要:作用域练习1 def test1(): print('in the test1') def test(): print('in the test') return test1 res = test() print(res()) #res = test1地址 函数没有return,默认返回None 作 阅读全文

posted @ 2019-02-18 20:44 yukun093 阅读(197) 评论(0) 推荐(0)

前向引用,全局变量和局部变量,递归函数
摘要:1.全局变量与局部变量练习 1 # -*- coding: UTF-8 -*- 2 def bar(): 3 print('from bar') 4 def foo(): 5 print('from foo') 6 bar() 7 foo() 8 9 name = 'lhf' 10 def chan 阅读全文

posted @ 2019-02-17 15:57 yukun093 阅读(218) 评论(0) 推荐(0)

字符串格式化,函数,组,递归,练习
摘要:1 # -*- coding: UTF-8 -*- 2 msg = 'i am {} my hobby is {}'.format('lhf',18) 3 print(msg) 4 5 msg1 = 'i am %s my hobby is %s' % ('lhf',[1,2]) 6 print(m 阅读全文

posted @ 2019-02-14 15:10 yukun093 阅读(262) 评论(0) 推荐(0)

导航