- 博客(43)
- 收藏
- 关注
原创 java 常见面试题
静态方法,一般都是非静态方法,除非想要方便调用才用static修饰。静态变量,只有一份拷贝。非静态变量,每个实例都会创建一次。static代码块,可以单独执行。修饰变量,被修饰的变量不可被更改。修饰类,被修饰的类不能被继承。修饰方法,防止被改写。
2023-08-02 17:15:46
106
原创 django:urls,views,templates三者之间的关系
django入门,程序是如何执行的,urls,views,templates 三者关系。争取做到深入浅出。
2022-10-24 21:26:49
681
原创 DRF序列化器与Model日期类型不一致报错
AttributeError: 'datetime.date' object has no attribute 'utcoffset'
2022-04-17 11:56:54
767
原创 No module named ‘bookdrt.urls‘&&文件名、目录名或卷标语法不正确。: ‘<frozen importlib._bootstrap>‘
django 启动异常No module named 'bookdrt.urls'文件名、目录名或卷标语法不正确。: '<frozen importlib._bootstrap>'
2022-04-17 10:34:22
463
原创 Django3.1.7常见错误
1.url路径名称和view 函数名称不一致url(r'^***showbooks***/$', views.showbooks, name='showbooks'),def ***showbook***(requests):showbooks showbook 两个名称不一致报如下错误:Traceback (most recent call last): File "D:\Program Files\python\lib\site-packages\django\urls\resol
2021-04-08 23:09:08
690
原创 python&pycryptodome:AES加密
'''self.base_url = b'http://127.0.0.1:8000/'self.key = b'W7v4D60fds2Cmk2U'self.iv = b'1172311105789011'phone = '18611001100'url = b'api/sec_get_guest_list/''''from Crypto.Cipher import AESimport requests,json,base64,unittestclass AESTest(unittest
2020-06-07 10:33:54
188
转载 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
152
转载 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
129
原创 文件写入
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
155
原创 列表应用
列表: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
334
原创 正则表达式-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
450
转载 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
186
转载 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
118
转载 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
106
转载 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
202
转载 装饰器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
91
转载 装饰器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
87
转载 装饰器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
97
转载 装饰器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
86
转载 飞机大战:抽取基类
# -*- 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
149
转载 飞机大战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
153
转载 飞机大战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
461
原创 笔记
桥接模式上网:1.禁用 vmnet1,vmnet82.直接选择桥接模式-连接到当前物理机网卡,虚拟机选择桥接模式即可不用其他任何设置myqsl:root/h4950911761.位置:E:\mysoft\mysql-5.6.34-winx64\bin2.net start MySQL-----2003-can’t connect to mysql server on ‘localhost...
2019-01-15 21:48:59
176
转载 闭包应用
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
223
转载 闭包
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
86
转载 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
122
原创 存储过程
show procedure statusshow create procedure proc_name;delimiter //create procedure p()beginselect * from sign_event;end//delimiter ;delimiter //create procedure p2(n int)beginselect * fro...
2019-01-15 21:09:05
214
转载 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
160
转载 简单工厂模式
class CarStore(object): def __init__(self): self.factory = Factory() def order(self, car_type): return self.factory.select_car_by_type(car_type)class Factory(object): def select_car_by_type...
2019-01-08 23:06:02
79
转载 工厂方法模式
class Store(object): def select_car(self): pass def order(self, car_type): return self.select_car(car_type)class BMWCarStore(Store): def select_car(self, car_type): return BMWFactory().se...
2019-01-08 23:03:20
76
原创 MD5
import time,hashibdef user_sign(request): if request.method = 'POST': client_time = request.POST.get('time','') client_sign = request.POST.get('sign','') else: return 'error' if client_tim...
2019-01-06 23:13:43
96
原创 接口测试
'''self.base_url = b'http://127.0.0.1:8000/'self.key = b'W7v4D60fds2Cmk2U'self.iv = b'1172311105789011'phone = '18611001100'url = b'api/sec_get_guest_list/''''from Crypto.Cipher import AESimpo...
2019-01-06 23:11:06
117
转载 私有方法
class Dog: #私有方法 def __send_msg(self): print("------正在发送短信------") #公有方法 def send_msg(self, new_money): if new_money>10000: self.__send_msg() e...
2019-01-06 23:04:08
95
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人