04 2021 档案

摘要:#方式一: #此配置文件和movie.sqlite同级目录下 app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///{}".format(os.path.join(os.path.dirname(__file__), 'movie.sqlite')) 阅读全文
posted @ 2021-04-23 23:25 ty1539 阅读(203) 评论(0) 推荐(0) 编辑
摘要:生产者消费者模式 import time def consumer(name): print("%s 准备吃包子啦!" %name) while True: baozi = yield print("包子[%s]来了,被[%s]吃了!" %(baozi,name)) def producer(nam 阅读全文
posted @ 2021-04-22 09:03 ty1539 阅读(44) 评论(0) 推荐(0) 编辑
摘要:优先级排序(具体的我也不太懂) def sort_priority(values,group): def helper(x): if x in group: print('在group',0,x) return (0,x) # print(values) print('不在group',1,x) r 阅读全文
posted @ 2021-04-21 14:21 ty1539 阅读(101) 评论(0) 推荐(0) 编辑
摘要:测试1: age = 19 def func1(): age = 73 def func2(): nonlocal age # global age # age = 11 print('func2 内',age) func2() print('func1 内',age) func1() print( 阅读全文
posted @ 2021-04-21 11:45 ty1539 阅读(46) 评论(0) 推荐(0) 编辑
摘要:init()函数和main()函数 1.这两个函数都是go语言中的保留函数。init()用于初始化信息,main()用于作为程序的入口 2.这两个函数定义的时候:不能有参数,返回值。只能由go程序白动调用,不能被引用。 3.init()函数可以定义在任意的包中,可以有多个。main()函数只能在ma 阅读全文
posted @ 2021-04-20 15:39 ty1539 阅读(577) 评论(0) 推荐(0) 编辑
摘要:level = 'L0' n = 22 def func(): level = 'L1' n = 33 s =88 print(locals()) def outer(): n = 44 level = 'L2' print(locals(),n) def inner(): level = 'L3' 阅读全文
posted @ 2021-04-19 23:05 ty1539 阅读(47) 评论(0) 推荐(0) 编辑
摘要:def selfAdd(a): a += a a_int = 1 print('a_int1:',a_int) selfAdd(a_int) print('a_int2:',a_int) 输出结果: a_int1: 1 a_int2: 1 a_list =[1,2] print('a_list1:' 阅读全文
posted @ 2021-04-19 22:54 ty1539 阅读(60) 评论(0) 推荐(0) 编辑
摘要:2.1.调用glob 遍历指定目录下的所有文件和文件夹,不递归遍历,需要手动完成递归遍历功能。 import glob as gb path = gb.glob('W:\word2pdf\*') for path in path: print ('方法一path: ',path) print(' ' 阅读全文
posted @ 2021-04-19 22:34 ty1539 阅读(401) 评论(0) 推荐(0) 编辑
摘要:class S(): def go(self): print ("go s go!") def stop(self): print ("stop A stop!") class A(): def go(self): print ("go A go!") def stop(self): print ( 阅读全文
posted @ 2021-04-19 22:22 ty1539 阅读(42) 评论(0) 推荐(0) 编辑
摘要:购买东西 #_*_ encoding: utf-8 _*_ @author: ty hery 2018/12/29 product_list = [ ('Iphone',5000), ('book',10), ('watch',10600), ('bike',800), ] shopping_lis 阅读全文
posted @ 2021-04-19 14:29 ty1539 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/8/28 class MySQL: def __init__(self,ip,port,id): self.id=id self.ip=ip self.port=port def tell_info(sel 阅读全文
posted @ 2021-04-19 09:29 ty1539 阅读(42) 评论(0) 推荐(0) 编辑
摘要:%timeit : 评估运行时间 %paste : 执行剪贴板代码 %run : 执行文件代码 %pdb : 自动调试 %pdb on 打开调试 在打开调试后,输出变量a的值 p a %pdb off 关闭调试 上下记录功能 比如说: _ 上一次输出的结果 __ 上上一次输出的结果 自动补全完整 方 阅读全文
posted @ 2021-04-17 11:29 ty1539 阅读(54) 评论(0) 推荐(0) 编辑
摘要:参考自: https://www.cnblogs.com/chengxuyuanaa/p/12849919.html #_*_ encoding: utf-8 _*_ @author: ty hery 2020/6/4 from collections import OrderedDict # co 阅读全文
posted @ 2021-04-17 10:52 ty1539 阅读(74) 评论(0) 推荐(0) 编辑
摘要:转自: https://www.cnblogs.com/meditator/p/7943582.html (转载:http://blog.csdn.net/passionkk/article/details/49929887) Python中 list,truple,str,dict这些都可以被迭代 阅读全文
posted @ 2021-04-16 21:18 ty1539 阅读(100) 评论(0) 推荐(0) 编辑
摘要:在ipython2中 In [1]: from random import randint In [11]: data = [randint(-10,10) for _ in xrange(20)] # randint(-10,10) 首尾都包含 In [12]: data Out[12]: [-7 阅读全文
posted @ 2021-04-16 20:28 ty1539 阅读(16) 评论(0) 推荐(0) 编辑
摘要:在类内部定义的函数,分为2大类: 1,绑定方法: 绑定给谁,就应该由谁调用,谁来调用就把调用者当作第一个参数自动传入 绑定到对象的方法: 在类内部定义的没有被任何装饰器修饰的,对象自动传值 绑定到类的方法: 在类内部定义的被装饰器classmethod修饰的方法 2,非绑定方法: 没有自动传值这么一 阅读全文
posted @ 2021-04-16 18:00 ty1539 阅读(175) 评论(0) 推荐(0) 编辑
摘要:反射:通过字符串映射到对象的属性 反射使用1 class s2: def f1(self): print('打印首页') return '首页' def f2(self): print('打印新闻') return '新闻' def f3(self): print('打印精华') return '精 阅读全文
posted @ 2021-04-16 17:24 ty1539 阅读(40) 评论(0) 推荐(0) 编辑
摘要:classonlymethodz作用:只能被类调用,不能被实例对象调用。 class A(object): bar = 1 def foo(self): print( 'foo') @staticmethod def static_foo(): print( 'static_foo') print 阅读全文
posted @ 2021-04-16 17:15 ty1539 阅读(63) 评论(0) 推荐(0) 编辑
摘要:property: 在新式类中,将类的方法变成属性,方便调用, 1,对他的get方法,添加@property装饰器, 对他的set方法和del方法要是同名函数的,添加@get方法对应的的函数名.setter, 对于python2 的经典类,只有类的get方法有效 class Student(obje 阅读全文
posted @ 2021-04-16 16:33 ty1539 阅读(122) 评论(0) 推荐(0) 编辑
摘要:##1, 赋值 Python中,对象的赋值都是进行对象引用(内存地址)传递, 赋值(=),就是创建了对象的一个新的引用,修改其中任意一个变量都会影响到另一个 will = ["Will", 28, ["Python", "C#", "JavaScript"]] wilber = will print 阅读全文
posted @ 2021-04-16 16:23 ty1539 阅读(107) 评论(0) 推荐(0) 编辑
摘要:# sort()是列表的方法,修改原列表使得它按照大小排序,没有返回值,返回None ``` In [90]: x = [4, 6, 2, 1, 7, 9] In [91]: x.sort() In [92]: x Out[92]: [1, 2, 4, 6, 7, 9] In [98]: aa = 阅读全文
posted @ 2021-04-16 15:23 ty1539 阅读(203) 评论(0) 推荐(0) 编辑
摘要:赋值 #_*_ encoding: utf-8 _*_ @author: ty hery 2020/6/22 print('赋值') will = ["Will", 28, ["Python", "C#", "JavaScript"]] wilber = will print('id_will',i 阅读全文
posted @ 2021-04-16 11:16 ty1539 阅读(38) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/16 import random def insert_sort(li): for i in range(1,len(li)): tmp = li[i] j = i - 1 print('开始的',i, 阅读全文
posted @ 2021-04-16 10:59 ty1539 阅读(41) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty heris #项目名称: pycharm_file 会自动替换为当前项目名称 #创建时间: 2018/5/6 会自动替换为当前日期 lst1 = [[0]*5]*5 print(lst1) # [[0, 0, 0, 0, 0] 阅读全文
posted @ 2021-04-15 23:09 ty1539 阅读(46) 评论(0) 推荐(0) 编辑
摘要:# 函数:string.join() # Python中有join()和os.path.join() # 两个函数,具体作用如下: # join(): 连接字符串数组。将字符串、元组、列表中的元素以指定的字符(分隔符)连接生成一个新的字符串 # os.path.join(): 将多个路径组合后返回 阅读全文
posted @ 2021-04-15 23:03 ty1539 阅读(1026) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty heris #项目名称: pycharm_file 会自动替换为当前项目名称 #创建时间: 2018/5/23 会自动替换为当前日期 '''Python内建了map()和reduce()函数。 如果你读过Google的那篇大名 阅读全文
posted @ 2021-04-15 22:36 ty1539 阅读(736) 评论(0) 推荐(0) 编辑
摘要:lambda是Python编程语言中使用频率较高的一个关键字。那么,什么是lambda?它有哪些用法?网上的文章汗牛充栋,可是把这个讲透的文章却不多。这里,我们通过阅读各方资料,总结了关于Python中的lambda的“一个语法,三个特性,四个用法,一个争论”。 一个语法 在Python中,lamb 阅读全文
posted @ 2021-04-15 22:33 ty1539 阅读(60) 评论(0) 推荐(0) 编辑
摘要:def num(): return [lambda x:i*x for i in range(4)] print('这是num(): ',list(num())) print([m(2) for m in num()]) for i in num(): print('每一个i:',i) 输出: 这是 阅读全文
posted @ 2021-04-15 22:31 ty1539 阅读(141) 评论(0) 推荐(0) 编辑
摘要:通过位置 time1 = '{}--{}--{} {}::{}::{}'.format(2018,11,'02',11,43,50) print(time1) time1 = '{4}--{5}--{3} {3}::{1}::{0}'.format(2018,11,'02',11,43,50) #f 阅读全文
posted @ 2021-04-15 22:25 ty1539 阅读(531) 评论(0) 推荐(0) 编辑
摘要:自调用函数的二分法 data = [1, 3, 6, 7, 9, 12, 14, 16, 17, 18, 20, 21, 22, 23, 30, 32, 33, 35] def binary_search(dataset,find_num): if len(dataset) > 1: mid = i 阅读全文
posted @ 2021-04-15 21:30 ty1539 阅读(64) 评论(0) 推荐(0) 编辑
摘要:求10到20之间的质数 for循环中,break完全破坏他自己的一层循环,for如果正常执行完,会触发下面的else,遇到break局不会触发else里面的代码了 for num in range(10, 20): # 迭代 10 到 20 之间的数字 for i in range(2, num): 阅读全文
posted @ 2021-04-15 16:56 ty1539 阅读(512) 评论(0) 推荐(0) 编辑
摘要:1, 简单版 # -*- coding: utf-8 -*- from flask import Flask from flask_restful import reqparse, abort, Api, Resource app = Flask(__name__) api = Api(app) c 阅读全文
posted @ 2021-04-15 16:41 ty1539 阅读(109) 评论(0) 推荐(0) 编辑
摘要:main.py from flask import Flask from flask import request from flask import render_template from flask import redirect from model import * # app=Flask 阅读全文
posted @ 2021-04-14 23:55 ty1539 阅读(91) 评论(0) 推荐(0) 编辑
摘要:#_*_coding:utf-8_*_ from flask import Flask from flask_mail import Mail,Message app = Flask(__name__) # 配置邮件:服务器/端口/传输层安全协议/邮箱名/密码 app.config.update( 阅读全文
posted @ 2021-04-14 23:47 ty1539 阅读(55) 评论(0) 推荐(0) 编辑
摘要:pyhton manage.py runserver -h 0.0.0.0 -p 8888 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, render_template, request f 阅读全文
posted @ 2021-04-14 23:44 ty1539 阅读(66) 评论(0) 推荐(0) 编辑
摘要:flask的orm的原始方法 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, render_template, request from flask_sqlalchemy import SQL 阅读全文
posted @ 2021-04-14 23:26 ty1539 阅读(112) 评论(0) 推荐(0) 编辑
摘要:1, 何谓表单? 表单是HTML页面中负责数据采集功能的部件。它往往由三个部分组成,即表单标签、表单域、表单按钮。我们可以通过表单,将用户输入的数据提交给服务端,并交由服务端进行处理。 表单标签 用于声明表单的范围,位于表单标签中的元素将被提交 语法:<form></form> 属性:Method, 阅读全文
posted @ 2021-04-14 11:08 ty1539 阅读(342) 评论(0) 推荐(0) 编辑
摘要:1,最简单的使用try except 多分支:被监测代码块抛出的异常有多种可能性,并且我们需要针对每一种异常类型都定制专门的处理逻辑 try: print(' >>1') # nameasdf print(' >>2') l = [1,2,3] # l[100] print(' >>3') d = 阅读全文
posted @ 2021-04-14 09:31 ty1539 阅读(444) 评论(0) 推荐(0) 编辑
摘要:是不是每次调整模板文件,就要停止flask服务器,重启flask服务器,再去浏览器刷新页面? 有没有办法自动完成这3步呢? 安装livereload即可, 仅仅把app.run() 改为下面的例子就可以了。 注意:现在只支持python3.7,不支持3.8,并且尽限于修改模板文件,或者静态文件,改p 阅读全文
posted @ 2021-04-13 17:37 ty1539 阅读(1312) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2020/4/6 from flask.views import View from flask import Flask, render_template, request,views,jsonify app = 阅读全文
posted @ 2021-04-13 16:29 ty1539 阅读(67) 评论(0) 推荐(0) 编辑
摘要:from flask import Flask,flash,render_template,request app = Flask(__name__) app.secret_key ='123' # 此处一定要有app.secret_key, 至于为什么还没搞明白 @app.route('/') d 阅读全文
posted @ 2021-04-13 11:20 ty1539 阅读(124) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 # Flask依赖一个实现wsgi协议的模块:werkzeug from werkzeug.wrappers import Request,Response @Request.applicati 阅读全文
posted @ 2021-04-13 10:28 ty1539 阅读(56) 评论(0) 推荐(0) 编辑
摘要:# coding:utf-8 def num_div(num1,num2): try: assert isinstance(num1,int) except AssertionError: print(num1,'num1不是int类型') try: assert isinstance(num2,i 阅读全文
posted @ 2021-04-13 10:18 ty1539 阅读(59) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, render_template, request, url_for, redirect from flask_sqlalchemy import 阅读全文
posted @ 2021-04-12 23:22 ty1539 阅读(77) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, request # from werkzeug.routing import BaseConverter app = Flask(__name_ 阅读全文
posted @ 2021-04-12 23:18 ty1539 阅读(1446) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 # 打开文件对象 f = open('03.txt','w') # 2,向文件写入内容 try: f.write('去你大爷的\n') print("写入成功了") except Excepti 阅读全文
posted @ 2021-04-12 23:16 ty1539 阅读(130) 评论(0) 推荐(1) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, request, abort, Response, make_response # from werkzeug.routing import B 阅读全文
posted @ 2021-04-12 23:15 ty1539 阅读(784) 评论(0) 推荐(0) 编辑
摘要:文件夹如下 文件: python进行cgi编程/cgi-bin/main.py #!/usr/bin/env python import cgi,cgitb from jkxy import * form1 = cgi.FieldStorage() num1=form1.getvalue("Num1 阅读全文
posted @ 2021-04-12 23:09 ty1539 阅读(587) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, url_for, current_app, redirect from werkzeug.routing import BaseConverte 阅读全文
posted @ 2021-04-12 22:56 ty1539 阅读(66) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, render_template, request from flask_sqlalchemy import SQLAlchemy app = F 阅读全文
posted @ 2021-04-12 22:50 ty1539 阅读(48) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, render_template, request app = Flask(__name__) @app.route('/index') def 阅读全文
posted @ 2021-04-12 22:40 ty1539 阅读(60) 评论(0) 推荐(0) 编辑
摘要:flask_script用法: #_*_ encoding: utf-8 _*_ @author: ty hery 2019/1/12 from flask_script import Manager from flask import Flask import sqlite3 app = Flas 阅读全文
posted @ 2021-04-12 22:29 ty1539 阅读(112) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, session, current_app, g # g 是临时的本App里面的变量对象,通过对象的方法保存数据 如 g.username='张三 阅读全文
posted @ 2021-04-12 22:20 ty1539 阅读(73) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, session, current_app, g # g 是临时的本App里面的变量对象,通过对象的方法保存数据 如 g.username='张三 阅读全文
posted @ 2021-04-12 22:19 ty1539 阅读(307) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, request, abort, Response, make_response, jsonify # from werkzeug.routing 阅读全文
posted @ 2021-04-12 22:17 ty1539 阅读(54) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/12/20 from flask import Flask, request, abort, Response, make_response, jsonify # from werkzeug.routing 阅读全文
posted @ 2021-04-12 22:16 ty1539 阅读(141) 评论(0) 推荐(0) 编辑
摘要:from flask import Flask from flask_restful import Api,Resource app = Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return 阅读全文
posted @ 2021-04-12 22:13 ty1539 阅读(41) 评论(0) 推荐(0) 编辑
摘要:1.add_url_rule函数 之前我们接触的视图都是函数,所以一般简称视图函数。其实视图也可以基于类来实现,类视图的好处是支持继承,但是类视图不能跟函数视图一样,写完类视图还需要通过app.add_url_rule()函数来进行注册。 app.add_url_rule(rule, endpoin 阅读全文
posted @ 2021-04-12 21:24 ty1539 阅读(492) 评论(0) 推荐(0) 编辑
摘要:Python垃圾回收机制 引用计数器为主, 标记清除和分代回收为辅, + 缓存机制 1.引用计数器 1.1 环状双向链表refchain 在python 程序中创建的任何对象都会放在refchain链表中. 在Python的C源码中有一个名为refchain的环状双向链表,这个链表比较牛逼了,因为P 阅读全文
posted @ 2021-04-12 14:32 ty1539 阅读(69) 评论(0) 推荐(0) 编辑
摘要:可以参考: https://www.cnblogs.com/linwenbin/p/10617242.html 在本地python虚拟环境安装 pip install fabric==1.14.0 # pip install ecdsa pip install PyCrypto 好似要做python 阅读全文
posted @ 2021-04-12 14:27 ty1539 阅读(68) 评论(0) 推荐(0) 编辑
摘要:Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统。它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意 阅读全文
posted @ 2021-04-11 23:29 ty1539 阅读(186) 评论(0) 推荐(0) 编辑
摘要:用 __new__方法 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/6 class Singleton(object): def __new__(cls): if not hasattr(cls,'_instance'): cls._instan 阅读全文
posted @ 2021-04-10 22:56 ty1539 阅读(59) 评论(0) 推荐(0) 编辑
摘要:函数的列表作为默认参数带来的问题 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/5 def extendList(val, list=[]): print('这个是开始之前列表: ',list) list.append(val) print(f'这 阅读全文
posted @ 2021-04-10 22:49 ty1539 阅读(102) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/6 def multipliers(): return [lambda x : i * x for i in range(4)] print ([m(2) for m in multipliers()] 阅读全文
posted @ 2021-04-10 22:30 ty1539 阅读(69) 评论(0) 推荐(0) 编辑
摘要:##生成器版斐波那契 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/5 def fibonacci(): a,b=0,1 while True: yield b a,b = b, a+b fib=fibonacci() print(type(fib 阅读全文
posted @ 2021-04-10 22:25 ty1539 阅读(278) 评论(0) 推荐(0) 编辑
摘要:# 查出类的所有key值 cls.__table__.columns.keys() cls.__table__.columns.values() self.__class__.__name__ __get__方法详解: https://blog.csdn.net/qq_34979346/articl 阅读全文
posted @ 2021-04-10 22:12 ty1539 阅读(93) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/6 def table_things(**kwargs): for name, value in kwargs.items(): print ('{0} = {1}'.format(name, valu 阅读全文
posted @ 2021-04-10 22:07 ty1539 阅读(266) 评论(0) 推荐(0) 编辑
摘要:#_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/6 class Parent(object): x = 1 class Child1(Parent): pass class Child2(Parent): pass print (Parent.x, 阅读全文
posted @ 2021-04-10 22:00 ty1539 阅读(106) 评论(0) 推荐(0) 编辑
摘要:cmd里的快捷键 ctrl+a : 跳到开头 ctrl+e : 跳到结尾 which vi 查看vi这么命令在哪个目录下 >> /uer/bin/vi git log 太多了看不完, 空格 往下看 q退出 ctrl+f往后走, ctrl+d 往前走 mkdir a && cd - 创建并进入啊目录 阅读全文
posted @ 2021-04-09 11:08 ty1539 阅读(1078) 评论(0) 推荐(0) 编辑
摘要:https://www.ixigua.com/6835268628095435271?id=6836958720258212359&logTag=9d395df5acc953382c22 一、MySQL架构图 并发控制 存储引擎 日志 redo log undo log binlog 慢查询日志 单 阅读全文
posted @ 2021-04-05 18:23 ty1539 阅读(48) 评论(0) 推荐(0) 编辑
摘要:此篇文章比较详细,写了些(?P\d+)等分组: https://www.cnblogs.com/zjltt/p/6955965.html https://www.cnblogs.com/shenjianping/p/11647473.html python-re模块 .,[],\d,\w,\s,\S 阅读全文
posted @ 2021-04-04 15:22 ty1539 阅读(77) 评论(0) 推荐(0) 编辑
摘要:在window上叫my.ini,linux上叫my.conf 阅读全文
posted @ 2021-04-04 15:02 ty1539 阅读(46) 评论(0) 推荐(0) 编辑
摘要:装饰器改变属性 def test1(): '''test1...''' print('test1') def test2(): '''test2...''' print('test2') print (test1.__name__) print (test1.__doc__) print (test 阅读全文
posted @ 2021-04-03 21:34 ty1539 阅读(36) 评论(0) 推荐(0) 编辑
摘要:1.调用glob glob.blob遍历指定目录下的所有文件和文件夹,不递归遍历,需要手动完成递归遍历功能。 注意windows用'2个\'和linux用'/',以及最后的'*' import glob as gb path = gb.glob('E:\\前端帮助文档\\*') print(path 阅读全文
posted @ 2021-04-03 21:19 ty1539 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2021-04-03 21:16 ty1539 阅读(36) 评论(0) 推荐(0) 编辑
摘要:![](https://img2020.cnblogs.com/blog/1304933/202104/1304933-20210403205034306-250965423.png) ![](https://img2020.cnblogs.com/blog/1304933/202104/1304933-20210403180910582-1703899232.png) ![](https://i 阅读全文
posted @ 2021-04-03 20:45 ty1539 阅读(52) 评论(0) 推荐(0) 编辑
摘要:实际代码 # lib1.py class Circle(object): def __init__(self, r): self.r = r def area(self): return self.r **2* 3.14 #lib2.py class Triangle(object): def __ 阅读全文
posted @ 2021-04-03 17:28 ty1539 阅读(90) 评论(0) 推荐(0) 编辑
摘要:子问题重复计算问题: ,运行结果很慢 ! 解决方法:设置缓存,先从缓存中查找,没有再重新计算放入缓存, 运行结果很快就出了了, 计算结果: 20365011074 对于走楼梯问题同样也适用 优化方法:对于多个同样的问题,每次添加cache很麻烦,所以新增装饰器来保存cache,调用瞬间就计算出来了结 阅读全文
posted @ 2021-04-03 15:44 ty1539 阅读(58) 评论(0) 推荐(0) 编辑
摘要:1. 协程 协程(Coroutine),也可以被称为微线程,是一种用户态内的上下文切换技术。简而言之,其实就是通过一个线程实现代码块相互切换执行。 在Python中有多种方式可以实现协程,例如: greenlet,是一个第三方模块,用于实现协程代码(Gevent协程就是基于greenlet实现) y 阅读全文
posted @ 2021-04-03 12:24 ty1539 阅读(231) 评论(0) 推荐(0) 编辑
摘要:深浅拷贝 Counter filter 过滤 列表排序 闭包 阅读全文
posted @ 2021-04-02 16:28 ty1539 阅读(57) 评论(0) 推荐(0) 编辑

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