python学习笔记_week20
1、Django请求的生命周期
路由系统 -> 视图函数(获取模板+数据=》渲染) -> 字符串返回给用户
2、路由系统
/index/ -> 函数或类.as_view()
/detail/(\d+) -> 函数(参数) 或 类.as_view()(参数)
/detail/(?P<nid>\d+) -> 函数(参数) 或 类.as_view()(参数)
/detail/ -> include("app01.urls") #路由的分发
/detail/ name='a1' -> include("app01.urls")
- 视图中:reverse
- 模板中:{% url "a1" %}
3、视图
FBV:函数
def index(request,*args,**kwargs):
..
CBV:类
class Home(views.View):
def get(self,reqeust,*args,**kwargs):
..
获取用户请求中的数据:
request.POST.get
request.GET.get
reqeust.FILES.get()
# checkbox,
........getlist() #多选
request.path_info
文件对象 = reqeust.FILES.get()
文件对象.name
文件对象.size
文件对象.chunks()
# <form 特殊的设置></form>
给用户返回数据:
render(request, "模板的文件的路径", {'k1': [1,2,3,4],"k2": {'name': '张扬','age': 73}})
redirect("URL")
HttpResponse(字符串)
4、模板语言
render(request, "模板的文件的路径", {'obj': 1234, 'k1': [1,2,3,4],"k2": {'name': '张扬','age': 73}})
<html>
<body>
<h1> {{ obj }} </h1>
<h1> {{ k1.3 }} </h1>
<h1> {{ k2.name }} </h1>
{% for i in k1 %}
<p> {{ i }} </p>
{% endfor %}
{% for row in k2.keys %}
{{ row }}
{% endfor %}
{% for row in k2.values %}
{{ row }}
{% endfor %}
{% for k,v in k2.items %}
{{ k }} - {{v}}
{% endfor %}
</body>
</html>
5、ORM
a. 创建类和字段
class User(models.Model):
age = models.IntergerFiled() #不需要指定长度
name = models.CharField(max_length=10)#字符长度
Python manage.py makemigrations
python manage.py migrate
# settings.py 注册APP
b. 操作
增
models.User.objects.create(name='qianxiaohu',age=18) dic = {'name': 'xx', 'age': 19}
models.User.objects.create(**dic) obj = models.User(name='qianxiaohu',age=18)
obj.save()
删
models.User.objects.filter(id=1).delete()
改
models.User.objects.filter(id__gt=1).update(name='alex',age=84)
dic = {'name': 'xx', 'age': 19}
models.User.objects.filter(id__gt=1).update(**dic)
查
models.User.objects.filter(id=1,name='root')
models.User.objects.filter(id__gt=1,name='root')
models.User.objects.filter(id__lt=1)
models.User.objects.filter(id__gte=1) #大于等于
models.User.objects.filter(id__lte=1) #小于等于 models.User.objects.filter(id=1,name='root')
dic = {'name': 'xx', 'age__gt': 19}
models.User.objects.filter(**dic)
v1 = models.Business.objects.all() # QuerySet ,内部元素都是对象
v2 = models.Business.objects.all().values('id','caption') # QuerySet ,内部元素都是字典
v3 = models.Business.objects.all().values_list('id','caption') # QuerySet ,内部元素都是元组 models.Business.objects.get(id=1)# 获取到的一个对象,如果不存在就报错
models.Business.objects.filter(id=1).first() #对象或者None 外键:
v = models.Host.objects.filter(nid__gt=0)
v[0].b.caption ----> 通过.进行跨表
外键:
class UserType(models.Model):
caption = models.CharField(max_length=32)
id caption
# 1,普通用户
# 2,VIP用户
# 3, 游客
class User(models.Model):
age = models.IntergerFiled()
name = models.CharField(max_length=10)#字符长度
# user_type_id = models.IntergerFiled() # 约束,
user_type = models.ForeignKey("UserType",to_field='id') # 约束,
name age user_type_id
# 张扬 18 3
# 张A扬 18 2
# 张B扬 18 2
张扬:
position:fixed absolute relative
Ajax
$.ajax({
url: '/host',
type: "POST",
data: {'k1': 123,'k2': "root"},
success: function(data){ #等着服务端返回信息自动执行
// data是服务器端返回的字符串
var obj = JSON.parse(data);
}
})
建议:永远让服务器端返回一个字典
return HttpResponse(json.dumps(字典)) #不能用redirect;用render时,用不了JSON
多对多:
创建多对多:
方式一:自定义关系表
class Host(models.Model):
nid = models.AutoField(primary_key=True)
hostname = models.CharField(max_length=32,db_index=True)
ip = models.GenericIPAddressField(protocol="ipv4",db_index=True)
port = models.IntegerField()
b = models.ForeignKey(to="Business", to_field='id')
#
class Application(models.Model):
name = models.CharField(max_length=32)
# 2
class HostToApp(models.Model):
hobj = models.ForeignKey(to='Host',to_field='nid')
aobj = models.ForeignKey(to='Application',to_field='id')
# HostToApp.objects.create(hobj_id=1,aobj_id=2) 方式二:自动创建关系表
class Host(models.Model):
nid = models.AutoField(primary_key=True)
hostname = models.CharField(max_length=32,db_index=True)
ip = models.GenericIPAddressField(protocol="ipv4",db_index=True)
port = models.IntegerField()
b = models.ForeignKey(to="Business", to_field='id')
#
class Application(models.Model):
name = models.CharField(max_length=32)
r = models.ManyToManyField("Host")
无法直接对第三张表进行操作
obj = Application.objects.get(id=1)
obj.name
# 第三张表操作
obj.r.add(1)
obj.r.add(2)
obj.r.add(2,3,4)
obj.r.add(*[1,2,3,4])
obj.r.remove(1)
obj.r.remove(2,4)
obj.r.remove(*[1,2,3])
obj.r.clear()
obj.r.set([3,5,7]) #只有3,5,7
# 所有相关的主机对象“列表” QuerySet
obj.r.all()
作业:
1、主机管理:增删改查
2、应用管理:增删改查
Ajax方式:数据量小
新URL方式:数据量大


from django.db import models
# Create your models here.
# class Foo(models.Model):
# name = models.CharField(max_length=1)
class Business(models.Model):
# id
caption = models.CharField(max_length=32)
code = models.CharField(max_length=32,null=True,default="SA")
# fk = models.ForeignKey('Foo')
class Host(models.Model):
nid = models.AutoField(primary_key=True)
hostname = models.CharField(max_length=32,db_index=True) #db_index创建索引
ip = models.GenericIPAddressField(protocol="both",db_index=True)
port = models.IntegerField()
b = models.ForeignKey(to="Business", to_field='id',on_delete=models.CASCADE)
#
class Application(models.Model):
name = models.CharField(max_length=32)
r = models.ManyToManyField("Host")
#
# class HostToApp(models.Model):
# hobj = models.ForeignKey(to='Host',to_field='nid')
# aobj = models.ForeignKey(to='Application',to_field='id') # hid: 1~10 aid:1~2
from django.shortcuts import render,HttpResponse,redirect
from app01 import models
import json
# Create your views here.
def business(request):
v1 = models.Business.objects.all()
# QuerySet
# [obj(id,caption,code),obj(id,caption,code),obj(id,caption,code) ] v2 = models.Business.objects.all().values('id','caption')
# QuerySet
# [{'id':1,'caption': ' 运维部'},{'id':1,'caption': '运维部'},...] v3 = models.Business.objects.all().values_list('id','caption')
# QuerySet
# [(1,运维部),(2,开发)]
return render(request, 'business.html', {'v1': v1,'v2': v2, 'v3': v3})
# def host(request):
# v1 = models.Host.objects.filter(nid__gt=0)
# # QuerySet [hostobj(ip.host,另外一个对象(..)),]
# # for row in v1:
# # print(row.nid,row.hostname,row.ip,row.port,row.b_id,row.b.caption,row.b.code,row.b.id,sep='\t')
# # print(row.b.fk.name)
# # return HttpResponse("Host")
# v2 = models.Host.objects.filter(nid__gt=0).values('nid','hostname','b_id','b__caption')
# # QuerySet: [ {} ]
# # print(v2)
# # for row in v2:
# # print(row['nid'],row['hostname'],row['b_id'],row['b__caption'])
# v3 = models.Host.objects.filter(nid__gt=0).values_list('nid','hostname','b_id','b__caption')
# # QuerySet: [ () ]
# return render(request, 'host.html', {'v1': v1,'v2': v2,'v3': v3})
def host(request):
if request.method == "GET":
v1 = models.Host.objects.filter(nid__gt=0)
v2 = models.Host.objects.filter(nid__gt=0).values('nid','hostname','b_id','b__caption')
v3 = models.Host.objects.filter(nid__gt=0).values_list('nid','hostname','b_id','b__caption')
b_list = models.Business.objects.all()
return render(request, 'host.html', {'v1': v1,'v2': v2,'v3': v3,'b_list':b_list})
elif request.method == "POST":
h = request.POST.get('hostname')
i = request.POST.get('ip')
p = request.POST.get('port')
b = request.POST.get('b_id')
# models.Host.objects.create(hostname=h,
# ip=i,
# port=p,
# b=models.Business.objects.get(id=b)
# )
models.Host.objects.create(hostname=h,
ip=i,
port=p,
b_id=b
)
return redirect('/host')
def test_ajax(request):
ret = {'status': True, 'error': None, 'data': None}
try:
h = request.POST.get('hostname')
i = request.POST.get('ip')
p = request.POST.get('port')
b = request.POST.get('b_id')
if h and len(h) > 5:
models.Host.objects.create(hostname=h,
ip=i,
port=p,
b_id=b)
else:
ret['status'] = False
ret['error'] = "太短了"
except Exception as e:
ret['status'] = False
ret['error'] = '请求错误'
return HttpResponse(json.dumps(ret))
def app(request):
if request.method == "GET":
app_list = models.Application.objects.all()
# for row in app_list:
# print(row.name,row.r.all())
host_list = models.Host.objects.all()
return render(request,'app.html',{"app_list": app_list,'host_list': host_list})
elif request.method == "POST":
app_name = request.POST.get('app_name')
host_list = request.POST.getlist('host_list')
print(app_name,host_list)
obj = models.Application.objects.create(name=app_name)
obj.r.add(*host_list)
return redirect('/app')
def ajax_add_app(request):
ret = {'status':True, 'error':None, 'data': None}
app_name = request.POST.get('app_name')
host_list = request.POST.getlist('host_list')
obj = models.Application.objects.create(name=app_name)
obj.r.add(*host_list)
return HttpResponse(json.dumps(ret))
import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '-j(nkf+hepu(^e=qr0s)$0bfb_%8*x0f@$22cf+3bn_-+i=d&0' # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app01',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ROOT_URLCONF = 's14day20.urls' TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
] WSGI_APPLICATION = 's14day20.wsgi.application' # Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
} # Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
] # Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
from django.conf.urls import url
from django.contrib import admin
from app01 import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^business$', views.business),
url(r'^host$', views.host),
url(r'^test_ajax$', views.test_ajax),
url(r'^app$', views.app),
url(r'^ajax_add_app$', views.ajax_add_app),
# url(r'^business_add', views.business),
]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.host-tag{
display: inline-block;
padding: 3px;
border: 1px solid red;
background-color: palevioletred;
}
.hide{
display: none;
}
.shade{
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: black;
opacity: 0.6;
z-index: 100;
}
.add-modal,.edit-modal{
position: fixed;
height: 300px;
width: 400px;
top:100px;
left: 50%;
z-index: 101;
border: 1px solid red;
background: white;
margin-left: -200px;
}
</style>
</head>
<body>
<h1>应用列表</h1>
<div>
<input id="add_app" type="button" value="添加" />
</div>
<table border="1">
<thead>
<tr>
<td>应用名称</td>
<td>应用主机列表</td>
</tr>
</thead>
<tbody>
{% for app in app_list %}
<tr aid="{{ app.id }}">
<td>{{ app.name }}</td>
<td>
{% for host in app.r.all %}
<span class="host-tag" hid="{{ host.nid }}"> {{ host.hostname }} </span>
{% endfor %}
</td>
<td>
<a class="edit">编辑</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="shade hide"></div>
<div class="add-modal hide">
<form id="add_form" method="POST" action="/app">
<div class="group">
<input id="app_name" type="text" placeholder="应用名称" name="app_name" />
</div>
<div class="group">
<select id="host_list" name="host_list" multiple>
{% for op in host_list %}
<option value="{{ op.nid }}">{{ op.hostname }}</option>
{% endfor %}
</select>
</div>
<input type="submit" value="提交" />
<input id="add_submit_ajax" type="button" value="Ajax提交" />
</form>
</div>
<div class="edit-modal hide">
<form id="edit_form" method="POST" action="/host">
<input type="text" name="nid" style="display:none" />
<input type="text" placeholder="应用名称" name="app" />
<select name="host_list" multiple>
{% for op in host_list %}
<option value="{{ op.nid }}">{{ op.hostname }}</option>
{% endfor %}
</select>
<a id="ajax_submit_edit" >确认编辑</a>
</form>
</div>
<script src="/static/jquery-1.12.4.js"></script>
<script>
$(function(){
$('#add_app').click(function(){
$('.shade,.add-modal').removeClass('hide');
});
$('#cancel').click(function(){
$('.shade,.add-modal').addClass('hide');
});
$('#add_submit_ajax').click(function(){
$.ajax({
url: '/ajax_add_app',
// data: {'user': 123,'host_list': [1,2,3,4]},
data: $('#add_form').serialize(),
type: "POST",
dataType: 'JSON', // jQuery内部自动做
traditional: true, //发列表
success: function(obj){
console.log(obj);
},
error: function () {
}
})
});
$('.edit').click(function(){
$('.edit-modal,.shade').removeClass('hide');
var hid_list = [];
$(this).parent().prev().children().each(function(){
var hid = $(this).attr('hid');
hid_list.push(hid)
});
$('#edit_form').find('select').val(hid_list);
// 如果发送到后台
/*
obj = models.Application.objects.get(id=aid)
obj.name = "新Name"
obj.save()
obj.r.set([1,2,3,4])
*/
})
})
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>业务线列表(对象)</h1>
<ul>
{% for row in v1 %}
<li>{{ row.id }} - {{ row.caption }} - {{ row.code }}</li>
{% endfor %}
</ul>
<h1>业务线列表(字典)</h1>
<ul>
{% for row in v2 %}
<li>{{ row.id }} - {{ row.caption }}</li>
{% endfor %}
</ul>
<h1>业务线列表(元组)</h1>
<ul>
{% for row in v3 %}
<li>{{ row.0 }} - {{ row.1 }}</li>
{% endfor %}
</ul>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.hide{
display: none;
}
.shade{
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: black;
opacity: 0.6;
z-index: 100;
}
.add-modal,.edit-modal{
position: fixed;
height: 300px;
width: 400px;
top:100px;
left: 50%;
z-index: 101;
border: 1px solid red;
background: white;
margin-left: -200px;
}
</style>
</head>
<body>
<h1>主机列表(对象)</h1>
<div>
<input id="add_host" type="button" value="添加" />
</div>
<table border="1">
<thead>
<tr>
<th>序号</th>
<th>主机名</th>
<th>IP</th>
<th>端口</th>
<th>业务线名称</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for row in v1 %}
<tr hid="{{ row.nid }}" bid="{{ row.b_id }}">
<td>{{ forloop.counter }}</td> {# 计数 #}
<td>{{ row.hostname }}</td>
<td>{{ row.ip }}</td>
<td>{{ row.port }}</td>
<td>{{ row.b.caption }}</td>
<td>
<a class="edit">编辑</a>|<a class="delete">删除</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<h1>主机列表(字典)</h1>
<table border="1">
<thead>
<tr>
<th>主机名</th>
<th>业务线名称</th>
</tr>
</thead>
<tbody>
{% for row in v2 %}
<tr hid="{{ row.nid }}" bid="{{ row.b_id }}">
<td>{{ row.hostname }}</td>
<td>{{ row.b__caption }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<h1>主机列表(元组)</h1>
<table border="1">
<thead>
<tr>
<th>主机名</th>
<th>业务线名称</th>
</tr>
</thead>
<tbody>
{% for row in v3 %}
<tr hid="{{ row.0 }}" bid="{{ row.2 }}">
<td>{{ row.1 }}</td>
<td>{{ row.3 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="shade hide"></div>
<div class="add-modal hide">
<form id="add_form" method="POST" action="/host"> {# 以form提交,页面会刷新 #}
<div class="group">
<input id="host" type="text" placeholder="主机名" name="hostname" />
</div>
<div class="group">
<input id="ip" type="text" placeholder="IP" name="ip" />
</div>
<div class="group">
<input id="port" type="text" placeholder="端口" name="port" />
</div>
<div class="group">
<select id="sel" name="b_id">
{% for op in b_list %}
<option value="{{ op.id }}">{{ op.caption }}</option>
{% endfor %}
</select>
</div>
<input type="submit" value="提交" />
<a id="ajax_submit" >悄悄提交</a>
<input id="cancel" type="button" value="取消" />
<span id="erro_msg" style="color: red"></span>
</form>
</div>
<div class="edit-modal hide">
<form id="edit_form" method="POST" action="/host">
<input type="text" name="nid" style="display:none" />
<input type="text" placeholder="主机名" name="hostname" />
<input type="text" placeholder="IP" name="ip" />
<input type="text" placeholder="端口" name="port" />
<select name="b_id">
{% for op in b_list %}
<option value="{{ op.id }}">{{ op.caption }}</option>
{% endfor %}
</select>
<a id="ajax_submit_edit" >确认编辑</a>
</form>
</div>
<script src="/static/jquery-1.12.4.js"></script>
<script>
$(function(){
$('#add_host').click(function(){
$('.shade,.add-modal').removeClass('hide');
});
$('#cancel').click(function(){
$('.shade,.add-modal').addClass('hide');
});
$('#ajax_submit').click(function(){
$.ajax({
url: "/test_ajax",
type: 'POST',
//data: {'hostname': $('#host').val(), 'ip': $('#ip').val(), 'port': $('#port').val(), 'b_id': $('#sel').val()},
data: $('#add_form').serialize(),{# 会把form所有的值打包发给后台 #}
success: function(data){ {# 服务器返回的消息在data中 #}
var obj = JSON.parse(data); {# 字符串转化为对象 #}
if(obj.status){
location.reload();
}else{
$('#erro_msg').text(obj.error);
}
}
})
});
$('.edit').click(function(){
$('.shade,.edit-modal').removeClass('hide');
var bid = $(this).parent().parent().attr('bid');
var nid = $(this).parent().parent().attr('hid');
$('#edit_form').find('select').val(bid);
$('#edit_form').find('input[name="nid"]').val(nid);
// 修改
/*
$.ajax({
data: $('#edit_form').serialize()
});
*/
// models.Host.objects.filter(nid=nid).update()
})
})
</script>
</body>
</html>
python学习笔记_week20的更多相关文章
- python学习笔记整理——字典
python学习笔记整理 数据结构--字典 无序的 {键:值} 对集合 用于查询的方法 len(d) Return the number of items in the dictionary d. 返 ...
- VS2013中Python学习笔记[Django Web的第一个网页]
前言 前面我简单介绍了Python的Hello World.看到有人问我搞搞Python的Web,一时兴起,就来试试看. 第一篇 VS2013中Python学习笔记[环境搭建] 简单介绍Python环 ...
- python学习笔记之module && package
个人总结: import module,module就是文件名,导入那个python文件 import package,package就是一个文件夹,导入的文件夹下有一个__init__.py的文件, ...
- python学习笔记(六)文件夹遍历,异常处理
python学习笔记(六) 文件夹遍历 1.递归遍历 import os allfile = [] def dirList(path): filelist = os.listdir(path) for ...
- python学习笔记--Django入门四 管理站点--二
接上一节 python学习笔记--Django入门四 管理站点 设置字段可选 编辑Book模块在email字段上加上blank=True,指定email字段为可选,代码如下: class Autho ...
- python学习笔记--Django入门0 安装dangjo
经过这几天的折腾,经历了Django的各种报错,翻译的内容虽然不错,但是与实际的版本有差别,会出现各种奇葩的错误.现在终于找到了解决方法:查看英文原版内容:http://djangobook.com/ ...
- python学习笔记(一)元组,序列,字典
python学习笔记(一)元组,序列,字典
- Pythoner | 你像从前一样的Python学习笔记
Pythoner | 你像从前一样的Python学习笔记 Pythoner
- OpenCV之Python学习笔记
OpenCV之Python学习笔记 直都在用Python+OpenCV做一些算法的原型.本来想留下发布一些文章的,可是整理一下就有点无奈了,都是写零散不成系统的小片段.现在看 到一本国外的新书< ...
随机推荐
- 解决Sublime Text 3中文显示乱码问题
之前用Sublime Text 2,阅读了你是猴子派的救兵吗写的博客解决Sublime Text 2中文显示乱码问题,解决了问题. 后来嫌版本2启动太慢了,换成Sublime Text 3之后,发现网 ...
- 【SpringBoot】支持Java1.6
开发环境 Java 1.6; 需要修改的配置 指定java和tomcat版本 <!-- TO Support JDK 1.6 start --> <java.version>1 ...
- 【Maven】从Maven中导出项目依赖的Jar包
从SVN上下载源代码 svn export https://10.200.1.201/xxxx/PLATFORM code/ --force --username xxx --password xxx ...
- bzoj4814: [Cqoi2017]小Q的草稿
Description 小Q是个程序员.众所周知,程序员在写程序的时候经常需要草稿纸.小Q现在需要一张草稿纸用来画图,但是桌上 只有一张草稿纸,而且是一张被用过很多次的草稿纸.草稿纸可以看作一个二维平 ...
- PAT 乙级 1048 数字加密(20) C++版
1048. 数字加密(20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 本题要求实现一种数字加密方法.首先固 ...
- 服务网关zuul之五:熔断
路由熔断 当我们的后端服务出现异常的时候,我们不希望将异常抛出给最外层,期望服务可以自动进行一降级.Zuul给我们提供了这样的支持.当某个服务出现异常时,直接返回我们预设的信息. 如果没有配置fall ...
- [ZZ]知名互联网公司Python的16道经典面试题及答案
知名互联网公司Python的16道经典面试题及答案 https://mp.weixin.qq.com/s/To0kYQk6ivYL1Lr8aGlEUw 知名互联网公司Python的16道经典面试题及答 ...
- HTML-CSS font-family:中文字体的英文名称
本文转自网络,找不到原地址了,在这里保留了作者名. font-family:中文字体的英文名称 ellisontang 发表于2011-07-15 16:33 宋体* SimSun 黑体* SimHe ...
- 三种通用应用层协议protobuf、thrift、avro对比,完爆xml,json,http
原文: https://www.douban.com/note/523340109/ Google protobuf: 优点 二进制消息,性能好/效率高(空间和时间效率都很不错) proto ...
- AnimationDrawable写贞动画,播放完毕停止在第一或最后一帧
animation.stop();animation.selectDrawable(0);//只需要在停止的时候,设置下标为你想要的一帧就好了