![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 57
C域
这个作者很懒,什么都没留下…
展开
-
python asyncio-nevnt loop库为什么能实现协程并发?
python asyncio为何能实现任务并发原创 2023-07-29 12:22:45 · 77 阅读 · 0 评论 -
python子类初始化同时继承父类
python 类与继承原创 2022-04-11 22:12:26 · 1344 阅读 · 0 评论 -
django-views
from django.shortcuts import render from django.http import * from .models import * # from django.template import RequestContext,loader def index(request): # temp=loader.get_template('booktest/in...转载 2019-02-18 23:03:41 · 85 阅读 · 0 评论 -
django-urls
from django.conf.urls import url from . import views urlpatterns=[ url(r'^$',views.index), url(r'^(\d+)$',views.show) ] from django.conf.urls import include, url from django.contrib import ...转载 2019-02-18 23:05:54 · 94 阅读 · 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 · 144 阅读 · 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 · 405 阅读 · 0 评论 -
列表应用
列表: list=['abc','123','hello'] 访问列表元素: print(list[0]) out:abc print(list[0].title()) out:Abc 访问最后一个元素: print(list[-1]) 修改元素列表: list[0] = 'aaa' 想列表中添加元素: 1.在列表末尾添加元素 list.append('bbb') 2.在列表中插入元素...原创 2019-03-05 16:51:02 · 291 阅读 · 0 评论 -
文件写入
f = 'file.txt' #覆盖原有内容 with open(f,'w') as file: file.write('hello') #自动创建 file2.txt with open('file2.txt','w') as file2: file2.write('hello') #不覆盖原有内容,在末尾继续添加 with open(f,'a') as file: file.wri...原创 2019-03-05 18:07:41 · 126 阅读 · 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 · 107 阅读 · 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 · 117 阅读 · 0 评论 -
django-admin
from django.contrib import admin from .models import * class HeroInfoInline(admin.TabularInline): model = HeroInfo extra = 3 class BookInfoAdmin(admin.ModelAdmin): list_display = ['id','...转载 2019-02-18 23:02:49 · 180 阅读 · 0 评论 -
装饰器4
def w1(func): print("---正在装饰1----") def inner(): print("---正在验证权限1----") func() return inner def w2(func): print("---正在装饰2----") def inner(): print("---正在验...转载 2019-01-22 23:22:06 · 67 阅读 · 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 · 63 阅读 · 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 · 134 阅读 · 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 · 102 阅读 · 0 评论 -
闭包
def test(number): print("--1--") def test_in(number2): print("--2--") print(number+number2) print("--3--") return test_in ret = test(100) print("-"*30) ret(1) ret(...转载 2019-01-15 21:45:54 · 70 阅读 · 0 评论 -
闭包应用
def test(a,b): def test_in(x): print(a*x+b) return test_in line1 = 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 · 179 阅读 · 0 评论 -
飞机大战2
# -*- coding:utf-8 -*- import pygame from 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 · 431 阅读 · 0 评论 -
飞机大战1
# -*- coding:utf-8 -*- import pygame from pygame.locals import * import time class HeroPlane(object): def __init__(self, screen_temp): self.x = 210 self.y = 700 self.scre...转载 2019-01-16 23:27:26 · 133 阅读 · 0 评论 -
装饰器1
def w1(func): def inner(): print("---正在验证权限----") func() return inner def f1(): print("---f1---") def f2(): print("---f2---") #innerFunc = w1(f1) #innerFunc() f1 = ...转载 2019-01-22 23:19:49 · 62 阅读 · 0 评论 -
装饰器2
def w1(func): def inner(): print("---正在验证权限----") if False: func() else: print("没有权限") return inner #f1 = w1(f1) @w1 def f1(): print("---f1...转载 2019-01-22 23:20:41 · 64 阅读 · 0 评论 -
飞机大战:抽取基类
# -*- coding:utf-8 -*- import pygame from pygame.locals import * import time import random class Base(object): def __init__(self, screen_temp, x, y, image_name): self.x = x self....转载 2019-01-17 23:46:22 · 127 阅读 · 0 评论