06 2019 档案

摘要:#装饰器:本质就是函数,功能是为其他函数添加附加功能 #原则:1.不修改被装饰函数的源代码 2.不修改被修饰函数的调用方式 #装饰器=高阶函数+函数嵌套+闭包 #函数嵌套: # def bar(): # print("form bar") # # # def foo(): # print("from foo") # def test(): # ... 阅读全文
posted @ 2019-06-26 07:15 coldplaycode 阅读(270) 评论(0) 推荐(0) 编辑
摘要:#我是用的window service2008系统,在配置服务器时由于是用php进行搭建 #首先我安装好phpstudy,通过服务器ip访问,显示了个helloworld,我查看了phpstudy里的端口和phppagehome #发现里面的首页和网站根目录是默认的路径页面,然后添加域名及根目录,将 阅读全文
posted @ 2019-06-20 10:41 coldplaycode 阅读(459) 评论(0) 推荐(0) 编辑
摘要:#高阶函数定义: #1.函数接受的一个参数是一个函数名 #2.函数的返回值是一个函数名 #3.满足上述条件任意一个,都可以称为高阶函数 #装饰器:本质就是函数,功能是为其他函数添加附加功能#原则:1.不修改被装饰函数的源代码 2.不修改被修饰函数的调用方式#装饰器=高阶函数+函数嵌套+闭包 import time # def test(func): # print(func) #... 阅读全文
posted @ 2019-06-20 09:09 coldplaycode 阅读(409) 评论(0) 推荐(0) 编辑
摘要:x="hello" #print(dir(x)) iter_test=x.__iter__() #print(iter_test) # print(iter_test.__next__()) # print(iter_test.__next__()) #可迭代对象就是迭代器 l=[1,2,3] # for i in l:#先执行i=l.__iter__() ,i.__next__() f... 阅读全文
posted @ 2019-06-17 22:12 coldplaycode 阅读(221) 评论(0) 推荐(0) 编辑
摘要:#文件合并与文件归档 #cat /etc/passwd > new_pass.txt (创建一个新的文档并将cat/etc/passwd的内容合并进来) #echo "xxxx" >> new_pass.txt(追加内容到文档末尾) #echo "xxxx" > new_pass.txt(写入新内容 阅读全文
posted @ 2019-06-12 16:54 coldplaycode 阅读(150) 评论(0) 推荐(0) 编辑
摘要:# f=open('code.txt','rb')#b的方式不能指定打开编码格式,以二进制的方式打开文件 # data=f.read() # print(data) # #encode 编码 decode解码 # print(data.decode(encoding="GBK")) # f.close() # # f=open("test22.py",'wb')#b的方式不能指定编码,以... 阅读全文
posted @ 2019-06-12 15:38 coldplaycode 阅读(180) 评论(0) 推荐(0) 编辑
摘要:#r w a 文件读取操作 默认打开为读操作 #f=open('coldplay.txt','r',encoding="utf-8")#open函数默认已系统编码方式打开windows默认编码方式为Gbk,如果我们文件存储的字符编码为utf-8#那么需要指定编码,防止乱码 #print(f) #data=f.read() #print(data) # print(f.readable())#判... 阅读全文
posted @ 2019-06-12 11:38 coldplaycode 阅读(165) 评论(0) 推荐(0) 编辑
摘要:#取绝对值 #print(abs(-1)) #对序列中的元素进行bool运算,如果可迭代对象为空也返回True # print(all((1,23,))) # print(all({"name":None})) # print(all('')) #对序列中的元素进行bool运算,如果可迭代对象中有一个为真,返回True # print(any([0,1,2,3])) # print(an... 阅读全文
posted @ 2019-06-10 07:39 coldplaycode 阅读(156) 评论(0) 推荐(0) 编辑
摘要:movie_people=["sb+_alex","sb_wupeiqi","han"] # def filter_test(array): # ret=[] # for p in array: # if not p.startswith('sb'): # ret.append(p) # # return ret # # end... 阅读全文
posted @ 2019-06-08 20:57 coldplaycode 阅读(242) 评论(0) 推荐(0) 编辑
摘要:#当前已什么用户登陆,创建的目录或文件,他的属组和主就是谁 #用户对目录拥有的几种权限 # ll -d查看目录当前权限信息 #r:可以查看该目录下的子文件名,子目录 #w:可以在该目录下创建,删除,重命名 #x:可以cd到该目录下 #如果当前目录没有权限,不影响其他目录已有权限 #chown 属主, 阅读全文
posted @ 2019-06-07 16:51 coldplaycode 阅读(131) 评论(0) 推荐(0) 编辑
摘要:#linux虚拟终端切换 ctrl+alt+F(1-6) 总共支持六个终端切换 #mkdir /root/boot/目录 在指定路径下新建目录 #touch /目录/文件名 在指定目录创建文件 #rm 文件名 删除文件 -f 文件名 强制删除文件,不需提示 -r 删除目录 -rf 删除文件和目录 # 阅读全文
posted @ 2019-06-06 13:28 coldplaycode 阅读(109) 评论(0) 推荐(0) 编辑
摘要:num_1=[1,2,10,5,3,7] # num_2=[] # for i in num_1: # num_2.append(i**2) # print(num_2) # def map_test(array): # num_2=[] # for i in num_1: # num_2.append(i**2) # return num_... 阅读全文
posted @ 2019-06-06 11:50 coldplaycode 阅读(153) 评论(0) 推荐(0) 编辑
摘要:#面向过程 #函数式编程:函数式=编程语言定义的函数+数学意义上的函数 #面向对象 #高阶函数:1.函数接受的参数是一个函数名 2.返回值中包含函数 # def foo(n):#n=bar # print(n) # # def bar(name): # print('my name is %s'%name) # # # foo(bar)#把函数当做参数传给另外一个函数 #... 阅读全文
posted @ 2019-06-06 11:47 coldplaycode 阅读(123) 评论(0) 推荐(0) 编辑
摘要:name="alex" def foo(): name="tang" #print(name) def bar(): print(name) return bar#函数名代表得就是一个函数的内存地址 # a=foo() # print(a) # print(a()) foo()()#由于函数bar包含在函数foo()中,所以bar会在自身查找打印... 阅读全文
posted @ 2019-06-06 11:45 coldplaycode 阅读(171) 评论(0) 推荐(0) 编辑
摘要:def calc(x): return x+1 a=calc(10) print(calc) print(lambda x:x+1)#lambda函数的内存地址,利用函数名可以作为值传递给变量 b=lambda x:x+1 print(b(10)) name="alex" # def change_name(x): # return x+'_sb' # # # res=ch... 阅读全文
posted @ 2019-06-06 11:38 coldplaycode 阅读(145) 评论(0) 推荐(0) 编辑
摘要:#递归特性: # 1.必须要有一个明确的结束条件 #2.每次进入更深一层递归时,问题规模相比上次递归都应有所减少 #3.递归效率不高,递归层次过多会导致栈溢出 def calc(n): print(n) if int(n / 2)==0: #// 取整 # /取商 #% 取余 #此处int是取整,商小于1的时候取整结... 阅读全文
posted @ 2019-06-06 11:34 coldplaycode 阅读(180) 评论(0) 推荐(0) 编辑
摘要:#超级用户root的家目录是/root ,而普通用户的家目录被存放在/home目录下 cd /目录 切换到指定目录 注意 / 是根目录 linux的一些重要目录 1.bin目录,用来存放常用的可执行文件 2.sbin,用来存放用户自己的文件或目录 3.home目录,用来存放用户自己的文件或目录 de 阅读全文
posted @ 2019-06-05 14:16 coldplaycode 阅读(115) 评论(0) 推荐(0) 编辑
摘要:#全局变量作用于全局或整个程序中,程序执行完毕后销毁,局部变量作用在当前函数中,调用函数执行完毕及销毁 #对于可变对象的修改,前面在python类型里的可变类型 list dict set 阅读全文
posted @ 2019-06-04 14:13 coldplaycode 阅读(151) 评论(0) 推荐(0) 编辑
摘要:#进入终端窗口,root命令提示符#,普通用户登陆提示符$,切换终端用户 ctrl+shift+F2,退出终端命令exit #init 0 关机 reboot 重启 ls查看当前目录下文件 ls -a 查看所有文件包括隐藏文件 ll -l 查看文件详细信息 #who am i 显示当前登陆用户 da 阅读全文
posted @ 2019-06-04 08:20 coldplaycode 阅读(141) 评论(0) 推荐(0) 编辑
摘要:#python中函数的定义:函数是逻辑结构化和过程化的一种编程方法,用来实现某些特定的功能.#python中函数简单定义的方法# def test(x):# "this is new function"# x+=1# return x#def:定义函数的关键字#test函数名#():括号内可定义形参 阅读全文
posted @ 2019-06-04 07:46 coldplaycode 阅读(218) 评论(0) 推荐(0) 编辑
摘要:#format拼接字符串,format()内的参数必须为可迭代的对象p1="i am {2},age {1},{0}".format("seven",18,'alex') print(tp1) tp1="i am {1},age {1}".format("seven",18,'alex')#按照元祖下标取值 print(tp1) tp1="i am {name},age {age},r... 阅读全文
posted @ 2019-06-03 07:47 coldplaycode 阅读(347) 评论(0) 推荐(0) 编辑
摘要:msg="I am "+"king" print(msg) print("I am %s of the %s" % ("tang","king"))#%s 字符串占位符 print("I am %s of age %s" % ("tang",[20,11]))#%s 字符串占位符 print("I am %s of the %d" % ("tang",1))#%d 整型占位符 #打印浮... 阅读全文
posted @ 2019-06-03 07:36 coldplaycode 阅读(118) 评论(0) 推荐(0) 编辑
摘要:#1.不同元素组成#2.无序#3.集合中的元素必须为不可变类型a={1,2,3,4,5,(1,2,3)}print(a)#随机向集合添加元素a.add("sjsj")print(id(a))#随机删除集合元素a.pop()print(id(a))#清空# a.clear()# print(a)#拷贝 阅读全文
posted @ 2019-06-02 23:51 coldplaycode 阅读(206) 评论(0) 推荐(0) 编辑
摘要:#字典#dict#基本结构info={ "k1":'v1' #键值对 ,"k2":"v2"}#字典的value可以是任何值# info={"k1":18,# 'k2':True,# 'k3':[11,22,55,{"kk1":'vv1',# 'kk2':'vv2',# 'kk3':(11,33,55 阅读全文
posted @ 2019-06-02 23:49 coldplaycode 阅读(179) 评论(0) 推荐(0) 编辑
摘要:#元组,元素不可被修改,不能被增加或者删除 #tuple,有序 tu=(11,22,33,44,55,33) #count 获取指定元素在元祖中出现的次数 print(tu.count(33)) #index获取元素的下标值,可以设置起始和结束位置 print(tu.index(33,3,8)) tu=(1,2,3,3,(455,666,888,),({"11":22,"name":"... 阅读全文
posted @ 2019-06-02 23:46 coldplaycode 阅读(338) 评论(0) 推荐(0) 编辑
摘要:#扩展原来的列表,参数是可迭代对象 阅读全文
posted @ 2019-06-02 23:35 coldplaycode 阅读(191) 评论(0) 推荐(0) 编辑
摘要:整型 int python3里,不管数字多大都是int类型 python2里面有长整型long 将整型字符串转换为数字 需要注意如果是浮点型的数字字符串,不能用int类型强制转换,而需要用float浮点类型 #当前数字的二进制位,至少用n位表示 #字符串类型的常见内置函数用法 字符串类型常用内置方法 阅读全文
posted @ 2019-06-01 11:43 coldplaycode 阅读(221) 评论(0) 推荐(0) 编辑

coldplaycode

点击右上角即可分享
微信分享提示