
python
文章平均质量分 57
C域
这个作者很懒,什么都没留下…
展开
-
python asyncio-nevnt loop库为什么能实现协程并发?
python asyncio为何能实现任务并发原创 2023-07-29 12:22:45 · 133 阅读 · 0 评论 -
python子类初始化同时继承父类
python 类与继承原创 2022-04-11 22:12:26 · 1454 阅读 · 0 评论 -
django-views
from django.shortcuts import renderfrom django.http import *from .models import *# from django.template import RequestContext,loaderdef index(request): # temp=loader.get_template('booktest/in...转载 2019-02-18 23:03:41 · 108 阅读 · 0 评论 -
django-urls
from django.conf.urls import urlfrom . import viewsurlpatterns=[ url(r'^$',views.index), url(r'^(\d+)$',views.show)]from django.conf.urls import include, urlfrom django.contrib import ...转载 2019-02-18 23:05:54 · 121 阅读 · 0 评论 -
django-html
index:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title></head><body><ul转载 2019-02-18 23:07:39 · 190 阅读 · 0 评论 -
正则表达式-1
\d:数字\w:字符.:任意字符*:任意数量字符+:至少一个?:0个或1个re.match(r'[a-zA-Z0-9]+\@[a-zA-Z0-9]+\.com','abc123@126.com')re.matcb(r'([A-Za-z0-9]+)\@([a-zA-Z0-9]+)\.com','Aw12@126.com')...原创 2019-03-05 16:21:31 · 452 阅读 · 0 评论 -
列表应用
列表:list=['abc','123','hello']访问列表元素:print(list[0])out:abcprint(list[0].title())out:Abc访问最后一个元素:print(list[-1])修改元素列表:list[0] = 'aaa'想列表中添加元素:1.在列表末尾添加元素list.append('bbb')2.在列表中插入元素...原创 2019-03-05 16:51:02 · 342 阅读 · 0 评论 -
文件写入
f = 'file.txt'#覆盖原有内容with open(f,'w') as file: file.write('hello')#自动创建 file2.txtwith open('file2.txt','w') as file2: file2.write('hello')#不覆盖原有内容,在末尾继续添加with open(f,'a') as file: file.wri...原创 2019-03-05 18:07:41 · 161 阅读 · 0 评论 -
django-get
#接收一键一值的情况def getTest2(request): #根据键接收值 a1=request.GET['a'] b1=request.GET['b'] c1=request.GET['c'] #构造上下文 context={'a':a1,'b':b1,'c':c1} #向模板中传递上下文,并进行渲染 return ren...转载 2019-03-24 23:17:28 · 132 阅读 · 0 评论 -
django-post
def postTest1(request): return render(request,'booktest/postTest1.html')def postTest2(request): uname=request.POST['uname'] upwd=request.POST['upwd'] ugender=request.POST.get('ugende...转载 2019-03-24 23:19:11 · 159 阅读 · 0 评论 -
django-admin
from django.contrib import adminfrom .models import *class HeroInfoInline(admin.TabularInline): model = HeroInfo extra = 3class BookInfoAdmin(admin.ModelAdmin): list_display = ['id','...转载 2019-02-18 23:02:49 · 206 阅读 · 0 评论 -
装饰器4
def w1(func): print("---正在装饰1----") def inner(): print("---正在验证权限1----") func() return innerdef w2(func): print("---正在装饰2----") def inner(): print("---正在验...转载 2019-01-22 23:22:06 · 94 阅读 · 0 评论 -
装饰器3
#定义函数:完成包裹数据def makeBold(fn): def wrapped(): print("----1---") return "<b>" + fn() + "</b>" return wrapped#定义函数:完成包裹数据def makeItalic(fn): def wrapped(): ...转载 2019-01-22 23:21:22 · 91 阅读 · 0 评论 -
property(1)
class Test(object): def __init__(self): self.__num = 100 @property def num(self): print("----getter----") return self.__num @num.setter def num(self, newNu...转载 2019-01-15 21:05:33 · 163 阅读 · 0 评论 -
property(2)
class Test(object): def __init__(self): self.__num = 100 def setNum(self, newNum): print("----setter----") self.__num = newNum def getNum(self): print("---...转载 2019-01-15 21:14:27 · 125 阅读 · 0 评论 -
闭包
def test(number): print("--1--") def test_in(number2): print("--2--") print(number+number2) print("--3--") return test_inret = test(100)print("-"*30)ret(1)ret(...转载 2019-01-15 21:45:54 · 89 阅读 · 0 评论 -
闭包应用
def test(a,b): def test_in(x): print(a*x+b) return test_inline1 = test(1,1)line1(0)line2 = test(10,4)line2(0)line1(0)##def createNum(a,b,x):# print(a*x+b)##a=1#b=1...转载 2019-01-15 21:46:43 · 251 阅读 · 0 评论 -
飞机大战2
# -*- coding:utf-8 -*-import pygamefrom pygame.locals import *import time'''说明1.按下b键,让玩家飞机爆炸 2.爆炸效果的原理是:换图片'''class Hero(object): def __init__(self, screen_temp): self.x = 210 ...转载 2019-01-16 23:25:59 · 467 阅读 · 0 评论 -
飞机大战1
# -*- coding:utf-8 -*-import pygamefrom pygame.locals import *import timeclass HeroPlane(object): def __init__(self, screen_temp): self.x = 210 self.y = 700 self.scre...转载 2019-01-16 23:27:26 · 157 阅读 · 0 评论 -
装饰器1
def w1(func): def inner(): print("---正在验证权限----") func() return innerdef f1(): print("---f1---")def f2(): print("---f2---")#innerFunc = w1(f1)#innerFunc()f1 = ...转载 2019-01-22 23:19:49 · 90 阅读 · 0 评论 -
装饰器2
def w1(func): def inner(): print("---正在验证权限----") if False: func() else: print("没有权限") return inner#f1 = w1(f1)@w1def f1(): print("---f1...转载 2019-01-22 23:20:41 · 100 阅读 · 0 评论 -
飞机大战:抽取基类
# -*- coding:utf-8 -*-import pygamefrom pygame.locals import *import timeimport randomclass Base(object): def __init__(self, screen_temp, x, y, image_name): self.x = x self....转载 2019-01-17 23:46:22 · 152 阅读 · 0 评论