开源web框架django知识总结(二)

开源web框架django知识总结(二)

接着开源web框架django知识总结(一)的知识继续讲解,url和视图函数
URL 结构

语法:
protocol://hostname[:port]/path[?query][#fragment]
实例:
http://tts.tmooc.cn/video/showVideo?menuld=657421&version=AID999#subject

Django如何处理url的请求

.1 、Django从配置中,根据ROOT_URLCONF找到主路由文件;默认情况下,该文件再项目同名目录下的urls;例如:mysite1/mysite1/urls.py

.2 、Django加载主路由文件中的urlpatterns变量[包含很多路由的数组]

.3、依次匹配urlpatterns中的path,匹配到第一个适合的终端后续匹配

.4、匹配成功 - 调用对应的视图函数处理请求,返回响应

.5、匹配失败 - 返回404响应

补充:清理多余无用的虚拟环境、项目

删除本环境:rmvirtualenv 环境名

sudo rm -rf 文件夹名(包含子文件夹和问价)

pycharm中清理

视图函数

视图函数是用于接收一个浏览器请求(HttpRequest对象)并通过HttpResponse对象返回响应的函数。此函数可以接受浏览器请求并根据业务逻辑返回相应的响应内容给浏览器

语法:def xxx_view(request[,其它参数…]):

​ return HttpResponse对象

新建:views.py

from django.http import HttpResponse

def pagg1_view(request):
    html = "

这是我的第一个页面

"
return HttpResponse(html)

urls.py

from django.contrib import admin
from django.urls import path
from . import views

urlpatterns = [
    path('admin/', admin.site.urls),
    # http://192.168.42.128:8000/page/2003 注:一旦自己开始写url,没指定http://127.0.0.1:8000,这个网址的火箭,就没了
    path('page/2003/',views.pagg1_view),
    # 注意下面几个写法
    path('page/2003',views.pagg1_view), #报错
	# http://192.168.42.128:8000/page
	path('page/',views.pagg1_view),
    path('page',views.pagg1_view),

]

一、路由配置

settings.py中的ROOT_URLCONF指定了主路由配置列表urloatterns的文件位置

# file:<项目名文件夹下>/urls.py
urlpatterns = [
	path('page/2003/',views.page_2003_view),
	...#此处配置主路由
]

path()函数
导入 from django.urls import path

​ 语法 path(route,views,name=None)

​ 参数

​ 1、route:字符串类型,匹配的请求路径

​ 2、views:指定路径所对应的试图处理函数的名称

​ 3、name:为地址起别名,在模板中地址反向解析时使用

练习: 建一个小网站

1、输入网址:http://127.0.0.1:8000,在网页中输出:这是我的首页

from django.http import HttpResponse

# http://127.0.0.1:8000/
# path('', views.index_view),
def index_view(request):
    html = "这是我的首页"
    return HttpResponse(html)

2、输入网址:http://127.0.0.1:8000/page/1,在网页中输出:这是编号为1的网页

#http://127.0.0.1:8000/page/1
#path('page/1', views.page1_view),
def page1_view(request):
    html = "这是编号为1的网页"
    return HttpResponse(html)

3、输入网址:http://127.0.0.1:8000/page/2,在网页中输出:这是编号为2的网页

#http://127.0.0.1:8000/page/2
#path('page/2', views.page2_view),
def page2_view(request):
    html = "这是编号为2的网页"
    return HttpResponse(html)

思考:建立如上一百个网页该怎么办?

例如:http://127.0.0.1:8000/page/3

​ http://127.0.0.1:8000/page/4

​ …

​ http://127.0.0.1:8000/page/100

#http://127.0.0.1:8000/page/3-100   #注意执行顺序,上面已经有了 path('page/1', views.page1_view),所以,不会往下面执行
#path('page/', views.pagen_view),
def pagen_view(request,pg):
    html = "这是编号为%s的网页!!!"%(pg)
    return HttpResponse(html)

path转换器

语法:<转化器类型:自定义名>

作用:若转换器类型匹配到对应类型的数据,则将数据按照关键字传参的方式传递给视图函数

例子:path(‘page/’,views.xxx)
开源web框架django知识总结(二)_第1张图片
练习:小计算器

​ 定义一个路由的格式为:http://127.0.0.1:8000/整数/操作字符串[add/sub/mul]整数,从路由中提取数据,做相应的操作后返回给浏览器

​ 效果如下:127.0.0.1:8000/100/add/200 页面显示结果:300

re_path()函数

​ 在url的匹配过程中可以使用正则表达式进行精确匹配

​ 语法:re_path(reg,view,name=xxx)

​ 正则表达式为命名分组模式(?Ppattern);匹配提取参数后用关键字传参方式传递给视图函数
开源web框架django知识总结(二)_第2张图片
开源web框架django知识总结(二)_第3张图片
开源web框架django知识总结(二)_第4张图片
主路由urls.py配置

from django.contrib import admin
from django.urls import path, re_path
from . import views

urlpatterns = [
    
    #http://127.0.0.1:8000/整数2位/操作符/整数2位   注意,如果把此行代码放在下面,会被path('//', views.cal_view),行取代,不会执行
    re_path(r'^(?P\d{1,2})/(?P\w+)/(?P\d{1,2})$', views.cal2_view),
    #http://127.0.0.1:8000/整数/操作符/整数
    path('//', views.cal_view),

    #http://127.0.0.1:8000/birthday/年4/月2/日2
    re_path(r'^birthday/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})$', views.birthday_view),
    #http://127.0.0.1:8000/birthday/月2/日2/年4
    re_path(r'^birthday/(?P\d{1,2})/(?P\d{1,2})/(?P\d{4})$', views.birthday_view)
]

views.py

from django.http import HttpResponse

# 思考:建立如上一百、一千、一万个网页该怎么办?
# http://127.0.0.1:8000/page/3-100
def pagen_view(request,pg):
    html = "这是编号为%s的网页!!!"%(pg)
    return HttpResponse(html)

#http://127.0.0.1:8000/整数/操作符/整数
#path('//', views.cal_view),
def cal_view(request,n,op,m):

    if op not in ['add', 'sub', 'mul']:
        return HttpResponse('Your op is wrong')

    result = 0
    if op == 'add':
        result = n + m
    elif op == 'sub':
        result = n - m
    elif op == 'mul':
        result = n * m

    return HttpResponse('结果为:%s'%(result))


# http://127.0.0.1:8000/整数2位/操作符/整数2位   注意,如果把此行代码放在下面,会被path('//', views.cal_view),行取代,不会执行
# re_path(r'^(?P\d{1,2})/(?P\w+)/(?P\d{1,2})$', views.cal2_view),
def cal2_view(request, x, op, y):

    html = 'x:%s op:%s y:%s'%(x, op, y)
    return HttpResponse(html)

#http://127.0.0.1:8000/birthday/年4/月2/日2
#re_path(r'^birthday/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})$', views.birthday_view),
def birthday_view(request, y, m, d):

    html = "生日为%s年%s月%s日"%(y,m,d)
    return HttpResponse(html)

#http://127.0.0.1:8000/birthday/月2/日2/年4
#re_path(r'^birthday/(?P\d{1,2})/(?P\d{1,2})/(?P\d{4})$', views.birthday_view)
def birthday_view1(request, y, m, d):

    html = "生日为%s月%s日%s年"%(m,d,y)
    return HttpResponse(html)

二、请求和响应

1、请求和响应

定义:请求,是指浏览器端通过HTTP协议发送给服务端的数据;响应,是指服务器端接收到请求后做响应的处理后,,再回复给浏览器段的数据
开源web框架django知识总结(二)_第5张图片
开源web框架django知识总结(二)_第6张图片
请求中的方法:

​ 根据HTTP标准,HTTP请求可以使用多种请求方法

​ HTTP1.0定义了三种请求方法:GET,POST,HEAD方法(了解)
开源web框架django知识总结(二)_第7张图片
HTTP1.1新增了五种请求方法:OPTIONS,PUT,DELETE,TRACE,CONNECT方法
开源web框架django知识总结(二)_第8张图片
Django中的请求:

​ 请求在Django中实则就是,视图函数的第一个参数,即HttpRequest对象

​ Django接收到http协议的请求后,会根据请求数据保温创建HttpRequest对象

​ HttpRequest对象,通过属性,描述了请求的所有相关信息

具体的一些值:

​ path_info:URL字符串

​ method:字符串,表示HTTP请求方法,常用值:‘GET’、‘POST’

​ GET:QuerDict查询字典的对象,包含get请求方式的所有数据

​ POST:QueryDict查询字典的对象,包含post请求方式的所有数据

​ FILES:类似于字典的对象,包含所有的上传文件信息

​ COOKIES:Python字典,包含所有的cookie,键和值都为字符串

​ session:类似字典的对象,表示当前的会话

​ body:字符串,请求体的内容(POST 、PUT)

​ scheme:请求协议(‘http’/‘https’)

​ request.get_full_path():请求完整的路径

​ request.META:请求中的元数据(消息头) request.META[‘REMOTE_ADDR’]:客户端IP地址

# views.py
from django.http import HttpResponse, HttpResponseRedirect

def test_request(request):

    print('path info is', request.path_info)
    print('method is', request.method)
    print('querystring is', request.GET)
    print('full path is', request.get_full_path())

    return HttpResponse('test request ok')
    #return HttpResponseRedirect('/page/1')
# urls.py
path('test_request', views.test_request),

Django中的响应对象:

​ 构造函数格式:HttpResponse(content=响应体,content_type=响应体数据类型,status=状态码)

​ 作用:向客户端浏览器返回响应,同时携带响应体内容

常见的content_type如下:

​ ‘text/html’(默认的,html文件)

​ ‘text/plain’(纯文本)

​ ‘text/css’(css文件)

​ ‘text/javascript’(js文件)

​ ‘multipart/form-data’(文件提交)

​ ‘application/json’(json传输)

​ ‘application/xml’(xml文件)
开源web框架django知识总结(二)_第9张图片

2、GET请求和POST请求

定义:
开源web框架django知识总结(二)_第10张图片
GET请求中,如果有数据需要传递给服务器,通常会用查询字符串(Query String)传递 。【注意:不要传递敏感数据】

URL格式:xxx?参数名1=值1&参数名2=值2… 如:http://127.0.0.1:8000/page1?a=100&b=200

服务器端接收参数,获取客户端请求GET请求提交的数据
开源web框架django知识总结(二)_第11张图片

#views.py

def test_get_post(request):

    if request.method == 'GET':
        print(request.GET)
        print(request.GET['a'])
        #问卷调查 - from get  兴趣爱好 - 复选框
        print(request.GET.getlist('a'))
        print(request.GET.get('c', 'no c'))
        return HttpResponse(POST_FORM)

    elif request.method == 'POST':
        #处理用户提交数据
        print('uname is', request.POST['uname'])
        return HttpResponse('post is ok')
    else:
        pass

    return HttpResponse('--test get post is ok--')
# urls.py

path('test_get_post', views.test_get_post),

思考:之前的计算器功能,能否拿查询字符串做?

​ http://127.0.0.1:8000/整数/操作符/整数

​ http://127.0.0.1:8000/cal?x=10&y=20&op=add

POST处理
开源web框架django知识总结(二)_第12张图片
服务端接收数据:通过request.method来判断是否为POST请求,如:
开源web框架django知识总结(二)_第13张图片
使用post方式接收客户端数据:
开源web框架django知识总结(二)_第14张图片

#在views.py中定义一个全局变量
POST_FORM = '''
用户名:
'''

取消csrf验证:禁止掉settings.py文件中MIDDLEWARE中的CsrfViewMiddleware的中间件

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',
]

三、Django的设计模式及模板层

MVC和MTV

传统的MVC

开源web框架django知识总结(二)_第15张图片
Django的MTV模式:
开源web框架django知识总结(二)_第16张图片

模板层、变量和标签

什么是模板?

。模板是可以根据字典数据动态变化的html网页

。模板可以根据视图中传递的字典数据动态生成响应的HTML网页

模板配置

创建模板文件夹<项目名>/templates

在settings.py中TEMPLATES配置项

。BACKEND:指定模板的引擎

。DIRS:模板的搜索目录(可以是一个或多个)

。APP_DIRS:是否要在应用中的templates文件夹中搜索模板文件

。OPTIONS:有关模板的选项

**配置项中,需修改部分:设置DIRS **

TEMPLATES = [
    {
     
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'django_pro12/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',
            ],
        },
    },
]

模板的加载方式

**方案1:**通过loader获取模板,通过HttpResponse进行响应,在视图函数中

# views.py

from django.template import loader
def test_html(request):
    #方案1
    t = loader.get_template('test_html.html')
    html = t.render()
    return HttpResponse(html)

在mysite1文件夹下新建templates文件夹,新建test_html.html

<!DOCTYPE html>
"en">

    "UTF-8">
    Title<<span class="token operator">/</span>title>
<<span class="token operator">/</span>head>
<body>

<h3><span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> username <span class="token punctuation">}</span><span class="token punctuation">}</span>是模板层的~~~~<<span class="token operator">/</span>h3>

<<span class="token operator">/</span>body>
<<span class="token operator">/</span>html>
</code></pre> 
  <p>urls.py文件中加入</p> 
  <pre><code class="prism language-powershell">path<span class="token punctuation">(</span><span class="token string">'test_html'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>test_html<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre> 
  <p>**方案2:**使用render()直接加载并响应模板,在视图函数中:</p> 
  <pre><code class="prism language-powershell"><span class="token keyword">from</span> django<span class="token punctuation">.</span>shortcuts import render
<span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span><span class="token string">'模板文件名'</span><span class="token punctuation">,</span><span class="token string">'字典数据'</span><span class="token punctuation">)</span>
</code></pre> 
  <pre><code class="prism language-powershell">def test_html<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:
    <span class="token comment">#方案1</span>
    <span class="token comment"># t = loader.get_template('test_html.html')</span>
    <span class="token comment"># html = t.render()</span>
    <span class="token comment"># return HttpResponse(html)</span>

    <span class="token comment">#方案2</span>
    <span class="token keyword">from</span> django<span class="token punctuation">.</span>shortcuts import render

    <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'test_html.html'</span><span class="token punctuation">)</span>
</code></pre> 
  <p>视图层与模板层之间的交互</p> 
  <p>。视图函数可以将Python变量封装到<strong>字典</strong>中传递到模板,样例:<br> <a href="http://img.e-com-net.com/image/info8/c8a888a4860747e581980612a8341923.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/c8a888a4860747e581980612a8341923.jpg" alt="开源web框架django知识总结(二)_第17张图片" width="563" height="183" style="border:1px solid black;"></a><br> 。模板中,我们可以使用{ {变量名}}的语法,调用视图传进来的变量</p> 
  <pre><code class="prism language-powershell"><span class="token keyword">from</span> django<span class="token punctuation">.</span>shortcuts import render
<span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span><span class="token string">'模板文件名'</span><span class="token punctuation">,</span><span class="token string">'字典数据'</span><span class="token punctuation">)</span>
</code></pre> 
  <pre><code class="prism language-powershell">def test_html<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:
    <span class="token comment">#方案1</span>
    <span class="token comment"># from django.template import loader</span>
    <span class="token comment"># t = loader.get_template('test_html.html')</span>
    <span class="token comment"># html = t.render()</span>
    <span class="token comment"># return HttpResponse(html)</span>

    <span class="token comment">#方案2</span>
    <span class="token keyword">from</span> django<span class="token punctuation">.</span>shortcuts import render
    dic = <span class="token punctuation">{
     </span><span class="token string">'username'</span>:<span class="token string">'guoxiaonao'</span><span class="token punctuation">,</span><span class="token string">'age'</span>:18<span class="token punctuation">}</span>

    <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'test_html.html'</span><span class="token punctuation">,</span> dic<span class="token punctuation">)</span>
</code></pre> 
  <h5>5、模板层、过滤器和继承</h5> 
  <p>模板层-变量:</p> 
  <p><a href="http://img.e-com-net.com/image/info8/be9c6869811c457ba314b6c76ec8c5c7.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/be9c6869811c457ba314b6c76ec8c5c7.jpg" alt="开源web框架django知识总结(二)_第18张图片" width="403" height="288" style="border:1px solid black;"></a><br> 在模板中使用变量的语法:</p> 
  <p><a href="http://img.e-com-net.com/image/info8/fe3ec227655e4e37a5cfffb0598af093.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/fe3ec227655e4e37a5cfffb0598af093.jpg" alt="开源web框架django知识总结(二)_第19张图片" width="246" height="283" style="border:1px solid black;"></a><br> views.py</p> 
  <pre><code class="prism language-powershell"><span class="token keyword">from</span> django<span class="token punctuation">.</span>shortcuts import render
def test_html_param<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:

    dic = <span class="token punctuation">{
     </span><span class="token punctuation">}</span>
    dic<span class="token punctuation">[</span><span class="token string">'int'</span><span class="token punctuation">]</span> = 88
    dic<span class="token punctuation">[</span><span class="token string">'str'</span><span class="token punctuation">]</span> = <span class="token string">'guoxiaonao'</span>
    dic<span class="token punctuation">[</span><span class="token string">'lst'</span><span class="token punctuation">]</span> = <span class="token punctuation">[</span><span class="token string">'Tom'</span><span class="token punctuation">,</span> <span class="token string">'Jack'</span><span class="token punctuation">,</span> <span class="token string">'Lily'</span><span class="token punctuation">]</span>
    dic<span class="token punctuation">[</span><span class="token string">'dict'</span><span class="token punctuation">]</span> = <span class="token punctuation">{
     </span><span class="token string">'a'</span>:9<span class="token punctuation">,</span> <span class="token string">'b'</span>:8<span class="token punctuation">}</span>
    dic<span class="token punctuation">[</span><span class="token string">'func'</span><span class="token punctuation">]</span> = say_hi
    dic<span class="token punctuation">[</span><span class="token string">'class_obj'</span><span class="token punctuation">]</span> = Dog<span class="token punctuation">(</span><span class="token punctuation">)</span>
    dic<span class="token punctuation">[</span><span class="token string">'script'</span><span class="token punctuation">]</span> = <span class="token string">'<script>alert(1111)</script>'</span>

    <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'test_html_param.html'</span><span class="token punctuation">,</span> dic<span class="token punctuation">)</span>

def say_hi<span class="token punctuation">(</span><span class="token punctuation">)</span>:
    <span class="token keyword">return</span> <span class="token string">'hahaha'</span>

<span class="token keyword">class</span> Dog:
    def say<span class="token punctuation">(</span>self<span class="token punctuation">)</span>:
        <span class="token keyword">return</span> <span class="token string">'wangwang'</span>

</code></pre> 
  <p>test_html_param.html</p> 
  <pre><code class="prism language-powershell"><<span class="token operator">!</span>DOCTYPE html>
<html lang=<span class="token string">"en"</span>>
<head>
    <meta charset=<span class="token string">"UTF-8"</span>>
    <title>测试变量<<span class="token operator">/</span>title>
<<span class="token operator">/</span>head>
<body>

<h3>int 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> int<span class="token punctuation">|</span>add:<span class="token string">"2"</span> <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>
<h3>str 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> str<span class="token punctuation">|</span>upper <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>
<h3>lst 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> lst <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>
<h3>lst 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> lst<span class="token punctuation">.</span>0 <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>
<h3>dict 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> dict <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>
<h3>dict<span class="token punctuation">[</span><span class="token string">'a'</span><span class="token punctuation">]</span> 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> dict<span class="token punctuation">.</span>a <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>
<h3><span class="token keyword">function</span> 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> func <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>
<h3>class_obj 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> class_obj<span class="token punctuation">.</span>say <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>
<h3>script 是 <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> script<span class="token punctuation">|</span>safe <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>h3>


<<span class="token operator">/</span>body>
<<span class="token operator">/</span>html>
</code></pre> 
  <p>urls.py</p> 
  <pre><code class="prism language-powershell">path<span class="token punctuation">(</span><span class="token string">'test_html_param'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>test_html_param<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre> 
  <p><strong>模板标签</strong></p> 
  <p>作用:将一些服务器端的功能嵌入到模板中,例如流程控制</p> 
  <p>标签语法 {% 标签 %}…{% 结束标签 %}</p> 
  <p>**if 标签 **</p> 
  <p>语法 {% if 条件表达式1 %} … {% elif 条件表达式2 %} … {% elif 条件表达式3 %} …{% else %} …{% endif %}</p> 
  <p><a href="http://img.e-com-net.com/image/info8/e9b0a7bffd924a8a97810cb12b20ba23.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/e9b0a7bffd924a8a97810cb12b20ba23.jpg" alt="开源web框架django知识总结(二)_第20张图片" width="650" height="200" style="border:1px solid black;"></a></p> 
  <pre><code class="prism language-powershell"><span class="token comment"># views.py</span>
def test_if_for<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:

    dic = <span class="token punctuation">{
     </span><span class="token punctuation">}</span>
    dic<span class="token punctuation">[</span><span class="token string">'x'</span><span class="token punctuation">]</span> = 20
    dic<span class="token punctuation">[</span><span class="token string">'lst'</span><span class="token punctuation">]</span> = <span class="token punctuation">[</span><span class="token string">'Tom'</span><span class="token punctuation">,</span> <span class="token string">'Jack'</span><span class="token punctuation">,</span> <span class="token string">'Lily'</span><span class="token punctuation">]</span>
    <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'test_if_for.html'</span><span class="token punctuation">,</span> dic<span class="token punctuation">)</span>
</code></pre> 
  <pre><code class="prism language-powershell"><span class="token comment"># test_if_for.html</span>
<<span class="token operator">!</span>DOCTYPE html>
<html lang=<span class="token string">"en"</span>>
<head>
    <meta charset=<span class="token string">"UTF-8"</span>>
    <title>测试<span class="token keyword">if</span> 和 <span class="token keyword">for</span><<span class="token operator">/</span>title>
<<span class="token operator">/</span>head>
<body>

<span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">if</span> x > 10 <span class="token operator">%</span><span class="token punctuation">}</span>
今天天气很好
<span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">else</span> <span class="token operator">%</span><span class="token punctuation">}</span>
今天天气非常好
<span class="token punctuation">{
     </span><span class="token operator">%</span> endif <span class="token operator">%</span><span class="token punctuation">}</span>

<br>

<span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">for</span> name in lst <span class="token operator">%</span><span class="token punctuation">}</span>
    <span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">if</span> forloop<span class="token punctuation">.</span>first <span class="token operator">%</span><span class="token punctuation">}</span> &&&&& <span class="token punctuation">{
     </span><span class="token operator">%</span> endif <span class="token operator">%</span><span class="token punctuation">}</span>
    <p> <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> forloop<span class="token punctuation">.</span>counter <span class="token punctuation">}</span><span class="token punctuation">}</span>  <span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> name <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>p>
    <span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">if</span> forloop<span class="token punctuation">.</span>last <span class="token operator">%</span><span class="token punctuation">}</span> ===== <span class="token punctuation">{
     </span><span class="token operator">%</span> endif <span class="token operator">%</span><span class="token punctuation">}</span>
<span class="token punctuation">{
     </span><span class="token operator">%</span> empty <span class="token operator">%</span><span class="token punctuation">}</span>
    当前没数据
<span class="token punctuation">{
     </span><span class="token operator">%</span> endfor <span class="token operator">%</span><span class="token punctuation">}</span>

<<span class="token operator">/</span>body>
<<span class="token operator">/</span>html>
</code></pre> 
  <pre><code class="prism language-powershell"><span class="token comment"># urls.py</span>
path<span class="token punctuation">(</span><span class="token string">'test_if_for'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>test_if_for<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre> 
  <p>mycal.html</p> 
  <pre><code class="prism language-powershell"><form action=<span class="token string">'/mycal'</span> method=<span class="token string">'post'</span>>
    <input <span class="token function">type</span>=<span class="token string">'text'</span> name=<span class="token string">"x"</span> value=<span class="token string">"{
     { x }}"</span>>
    <<span class="token function">select</span> name=<span class="token string">'op'</span>>
    <option value=<span class="token string">"add"</span>  <span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">if</span> op == <span class="token string">'add'</span> <span class="token operator">%</span><span class="token punctuation">}</span>selected<span class="token punctuation">{
     </span><span class="token operator">%</span> endif <span class="token operator">%</span><span class="token punctuation">}</span> > <span class="token operator">+</span>加<<span class="token operator">/</span>option>
    <option value=<span class="token string">"sub"</span>  <span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">if</span> op == <span class="token string">'sub'</span> <span class="token operator">%</span><span class="token punctuation">}</span>selected<span class="token punctuation">{
     </span><span class="token operator">%</span> endif <span class="token operator">%</span><span class="token punctuation">}</span>> <span class="token operator">-</span>减<<span class="token operator">/</span>option>
    <option value=<span class="token string">"mul"</span>  <span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">if</span> op == <span class="token string">'mul'</span> <span class="token operator">%</span><span class="token punctuation">}</span>selected<span class="token punctuation">{
     </span><span class="token operator">%</span> endif <span class="token operator">%</span><span class="token punctuation">}</span>> <span class="token operator">*</span>乘<<span class="token operator">/</span>option>
    <option value=<span class="token string">"div"</span>  <span class="token punctuation">{
     </span><span class="token operator">%</span> <span class="token keyword">if</span> op == <span class="token string">'div'</span> <span class="token operator">%</span><span class="token punctuation">}</span>selected<span class="token punctuation">{
     </span><span class="token operator">%</span> endif <span class="token operator">%</span><span class="token punctuation">}</span>> <span class="token operator">/</span>除<<span class="token operator">/</span>option>
    <<span class="token operator">/</span><span class="token function">select</span>>
    <input <span class="token function">type</span>=<span class="token string">'text'</span> name=<span class="token string">"y"</span> value=<span class="token string">"{
     { y }}"</span>> = <span><span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> result <span class="token punctuation">}</span><span class="token punctuation">}</span><<span class="token operator">/</span>span>
    <div><input <span class="token function">type</span>=<span class="token string">"submit"</span> value=<span class="token string">'开始计算'</span>><<span class="token operator">/</span>div>
<<span class="token operator">/</span>form>
</code></pre> 
  <p>views.py</p> 
  <pre><code class="prism language-powershell">def test_mycal<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:

    <span class="token keyword">if</span> request<span class="token punctuation">.</span>method == <span class="token string">'GET'</span>:
        <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'mycal.html'</span><span class="token punctuation">)</span>
    elif request<span class="token punctuation">.</span>method == <span class="token string">'POST'</span>:
        <span class="token comment">#处理计算</span>
        x = int<span class="token punctuation">(</span>request<span class="token punctuation">.</span>POST<span class="token punctuation">[</span><span class="token string">'x'</span><span class="token punctuation">]</span><span class="token punctuation">)</span>   <span class="token comment"># 要确认传来数据类型</span>
        y = int<span class="token punctuation">(</span>request<span class="token punctuation">.</span>POST<span class="token punctuation">[</span><span class="token string">'y'</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
        op = request<span class="token punctuation">.</span>POST<span class="token punctuation">[</span><span class="token string">'op'</span><span class="token punctuation">]</span>

        result = 0
        <span class="token keyword">if</span> op == <span class="token string">'add'</span>:
            result = x <span class="token operator">+</span> y
        elif op == <span class="token string">'sub'</span>:
            result = x <span class="token operator">-</span> y
        elif op == <span class="token string">'mul'</span>:
            result = x <span class="token operator">*</span> y
        elif op == <span class="token string">'div'</span>:
            result = x <span class="token operator">/</span> y

        <span class="token comment">#dic={'x':x, 'y':y, 'op':op}</span>
        <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'mycal.html'</span><span class="token punctuation">,</span> locals<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>  <span class="token comment"># locals() 返回变量dic={'x':x, 'y':y, 'op':op}</span>
</code></pre> 
  <p>urls.py</p> 
  <pre><code class="prism language-powershell">path<span class="token punctuation">(</span><span class="token string">'mycal'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>test_mycal<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre> 
  <p><strong>模板层过滤器</strong></p> 
  <p>定义:在变量输出时对变量的值进行处理</p> 
  <p>作用:可以通过使用过滤器来改变变量的输出显示</p> 
  <p>语法:{ {变量|过滤器1:‘参数值1’|过滤器2:‘参数值2’…}}<br> <a href="http://img.e-com-net.com/image/info8/f4794b015cce4df1950f46d1fc4f7f22.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/f4794b015cce4df1950f46d1fc4f7f22.jpg" alt="开源web框架django知识总结(二)_第21张图片" width="607" height="359" style="border:1px solid black;"></a><br> <strong>模板的继承</strong><br> <a href="http://img.e-com-net.com/image/info8/a59eba614f834b60bf93c04280907218.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/a59eba614f834b60bf93c04280907218.jpg" alt="开源web框架django知识总结(二)_第22张图片" width="650" height="310" style="border:1px solid black;"></a><br> 定义:模板继承可以使用父模板的内容重用,子模板直接继承父模板的全部内容并可以覆盖父模板中响应的块</p> 
  <p>语法:父模板中:</p> 
  <p>​ 定义父模板中的块block标签</p> 
  <p>​ 标识出哪些在子模块中是允许被修改的</p> 
  <p>​ block标签:在父模板中定义,可以在子模板中覆盖</p> 
  <p>语法:子模板中:</p> 
  <p>​ 继承模板extends标签(写在模板文件的第一行) 例如:{% extends ‘base.html’ %}</p> 
  <p>​ 子模板重写父模板中的内容块 {% block block_name %} 子模板用来覆盖父模板中 block_name块的内容 {% endblock block_name %}</p> 
  <p>views.py</p> 
  <pre><code class="prism language-powershell">def base_view<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:
    lst = <span class="token punctuation">[</span><span class="token string">'Tom'</span><span class="token punctuation">,</span> <span class="token string">'Jack'</span><span class="token punctuation">]</span>
    <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'base.html'</span><span class="token punctuation">,</span> locals<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>

def music_view<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:

    <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'music.html'</span><span class="token punctuation">)</span>

def sport_view<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:

    <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'sport.html'</span><span class="token punctuation">)</span>
</code></pre> 
  <p>templates文件夹下base.html</p> 
  <pre><code class="prism language-powershell"><<span class="token operator">!</span>DOCTYPE html>
<html lang=<span class="token string">"en"</span>>
<head>
    <meta charset=<span class="token string">"UTF-8"</span>>
    <span class="token punctuation">{
     </span><span class="token operator">%</span> block mytitle <span class="token operator">%</span><span class="token punctuation">}</span>
    <title>主页<<span class="token operator">/</span>title>
    <span class="token punctuation">{
     </span><span class="token operator">%</span> endblock <span class="token operator">%</span><span class="token punctuation">}</span>
<<span class="token operator">/</span>head>
<body>
<span class="token punctuation">{
     </span><span class="token punctuation">{
     </span> lst <span class="token punctuation">}</span><span class="token punctuation">}</span>
<a href=<span class="token string">"/music_index"</span>>音乐频道<<span class="token operator">/</span>a>
<a href=<span class="token string">"/sport_index"</span>>体育频道<<span class="token operator">/</span>a>
<br>

<span class="token punctuation">{
     </span><span class="token operator">%</span> block info <span class="token operator">%</span><span class="token punctuation">}</span>
    这是主页
<span class="token punctuation">{
     </span><span class="token operator">%</span> endblock <span class="token operator">%</span><span class="token punctuation">}</span>

<br>

<h3>有任何问题联系xxxx<<span class="token operator">/</span>h3>
</code></pre> 
  <p>templates文件夹下music.html</p> 
  <pre><code class="prism language-powershell"><span class="token punctuation">{
     </span><span class="token operator">%</span> extends <span class="token string">'base.html'</span> <span class="token operator">%</span><span class="token punctuation">}</span>

<span class="token punctuation">{
     </span><span class="token operator">%</span> block mytitle <span class="token operator">%</span><span class="token punctuation">}</span>
    <title>音乐频道<<span class="token operator">/</span>title>
<span class="token punctuation">{
     </span><span class="token operator">%</span> endblock <span class="token operator">%</span><span class="token punctuation">}</span>

<span class="token punctuation">{
     </span><span class="token operator">%</span> block info <span class="token operator">%</span><span class="token punctuation">}</span>
    欢迎来到音乐频道
<span class="token punctuation">{
     </span><span class="token operator">%</span> endblock <span class="token operator">%</span><span class="token punctuation">}</span>

</code></pre> 
  <p>templates文件夹下sport.html</p> 
  <pre><code class="prism language-powershell"><span class="token punctuation">{
     </span><span class="token operator">%</span> extends <span class="token string">'base.html'</span> <span class="token operator">%</span><span class="token punctuation">}</span>

<span class="token punctuation">{
     </span><span class="token operator">%</span> block mytitle <span class="token operator">%</span><span class="token punctuation">}</span>
    <title>体育频道<<span class="token operator">/</span>title>
<span class="token punctuation">{
     </span><span class="token operator">%</span> endblock <span class="token operator">%</span><span class="token punctuation">}</span>

<span class="token punctuation">{
     </span><span class="token operator">%</span> block info <span class="token operator">%</span><span class="token punctuation">}</span>
    欢迎来到体育频道
<span class="token punctuation">{
     </span><span class="token operator">%</span> endblock <span class="token operator">%</span><span class="token punctuation">}</span>

</code></pre> 
  <p>urls.py</p> 
  <pre><code class="prism language-powershell">path<span class="token punctuation">(</span><span class="token string">'base_index'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>base_view<span class="token punctuation">,</span> name=<span class="token string">'base_index'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    path<span class="token punctuation">(</span><span class="token string">'music_index'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>music_view<span class="token punctuation">)</span><span class="token punctuation">,</span>
    path<span class="token punctuation">(</span><span class="token string">'sport_index'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>sport_view<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre> 
  <p>重写的覆盖规则</p> 
  <p>​ 不重写,将按照父模板的效果显示;重写,按照重写效果显示</p> 
  <p>​ 注意:模板继承时,服务器端的动态内容无法继承</p> 
  <h5>6、url反向解析</h5> 
  <p>代码中url出现的位置</p> 
  <p><strong>模板【html中】</strong></p> 
  <pre><code class="prism language-powershell"><a href=<span class="token string">'url'</span>>超链接<<span class="token operator">/</span>a>
</code></pre> 
  <p>点击后,页面跳转至url</p> 
  <pre><code class="prism language-powershell"><form action=<span class="token string">'url'</span> method=<span class="token string">'post'</span>>
</code></pre> 
  <p>form表单中的数据 用post方法提交至url</p> 
  <p><strong>视图函数中,302跳转 HttpResponseRedirect(‘url’)</strong></p> 
  <p>将用户地址栏中的地址跳转到url</p> 
  <p><strong>代码中url书写规范</strong></p> 
  <p>。绝对地址: http://127.0.0.1:8000/page/1</p> 
  <p>。相对地址1:1,’/page/1’ —’/’ 开头的相对地址,浏览器会把当前地址栏里的协议、ip和端口加上这个地址,作为最终访问地址,即如果当前页面地址栏为 http://127.0.0.1:8000/page/3;当前相对地址最终结果为 http://127.0.0.1:8000 + /page/1</p> 
  <p>。相对地址2: 2,‘page/1’ 没有’/’ 开头的相对地址,浏览器会根据当前url的最后一个/之前的内容,加上该相对地址,最为最终访问地址,例如当前地址栏地址为 http://127.0.0.1:8000/topic/detail;则该相对地址最终结果为 http://127.0.0.1:8000/topic/ + page/1</p> 
  <p>views.py</p> 
  <pre><code class="prism language-powershell">def test_url<span class="token punctuation">(</span>request<span class="token punctuation">)</span>:

    <span class="token keyword">return</span> render<span class="token punctuation">(</span>request<span class="token punctuation">,</span> <span class="token string">'test_url.html'</span><span class="token punctuation">)</span>

def test_url_result<span class="token punctuation">(</span>request<span class="token punctuation">,</span>age<span class="token punctuation">)</span>:
    <span class="token comment"># #302跳转</span>
    <span class="token comment"># from django.urls import reverse</span>
    <span class="token comment"># url = reverse('base_index')</span>
    <span class="token comment"># return HttpResponseRedirect(url)</span>
    <span class="token keyword">return</span> HttpResponse<span class="token punctuation">(</span><span class="token string">'---test url res is ok'</span><span class="token punctuation">)</span>
</code></pre> 
  <p>test_url.html</p> 
  <pre><code class="prism language-powershell"><<span class="token operator">!</span>DOCTYPE html>
<html lang=<span class="token string">"en"</span>>
<head>
    <meta charset=<span class="token string">"UTF-8"</span>>
    <title>测试url<<span class="token operator">/</span>title>
<<span class="token operator">/</span>head>
<body>

<br>
<a href=<span class="token string">"{% url 'tr' '100' %}"</span>>url反向解析版本<<span class="token operator">/</span>a>

<<span class="token operator">/</span>body>
<<span class="token operator">/</span>html>
</code></pre> 
  <p>urls.py</p> 
  <pre><code class="prism language-powershell"><span class="token comment">#http://127.0.0.1:8000/test/url</span>
    path<span class="token punctuation">(</span><span class="token string">'test/url'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>test_url<span class="token punctuation">)</span><span class="token punctuation">,</span>
    path<span class="token punctuation">(</span><span class="token string">'test_urls_result/<int:age>'</span><span class="token punctuation">,</span> views<span class="token punctuation">.</span>test_url_result<span class="token punctuation">,</span> name=<span class="token string">'tr'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre> 
  <p>url反向解析:是指在视图或模板中,用<strong>path定义的名称</strong>来<strong>动态查找或计算出相应路径的路由</strong></p> 
  <p>path函数的语法:</p> 
  <pre><code class="prism language-powershell">path<span class="token punctuation">(</span>route<span class="token punctuation">,</span>views<span class="token punctuation">,</span>name=<span class="token string">"别名"</span><span class="token punctuation">)</span>

​	path<span class="token punctuation">(</span><span class="token string">'page'</span><span class="token punctuation">,</span>views<span class="token punctuation">.</span>page_view<span class="token punctuation">,</span>name=<span class="token string">"page_url"</span><span class="token punctuation">)</span>
</code></pre> 
  <p>根据path中的 name= 关键字,传参给url确定了个唯一确定的名字,<strong>在模板中或视图中</strong>,可以通过这个名字反向推断出此url信息</p> 
  <pre><code class="prism language-powershell"><span class="token punctuation">{
     </span><span class="token operator">%</span> url <span class="token string">'别名'</span> <span class="token operator">%</span><span class="token punctuation">}</span>
<span class="token punctuation">{
     </span><span class="token operator">%</span> url <span class="token string">'别名'</span> <span class="token string">'参数值1'</span> <span class="token string">'参数值2'</span> <span class="token operator">%</span><span class="token punctuation">}</span>
ex:
<span class="token punctuation">{
     </span><span class="token operator">%</span> url <span class="token string">'pagen'</span> <span class="token string">'400'</span> <span class="token operator">%</span><span class="token punctuation">}</span>
<span class="token punctuation">{
     </span><span class="token operator">%</span> url <span class="token string">'person'</span> age=<span class="token string">'18'</span> name=<span class="token string">'gxn'</span> <span class="token operator">%</span><span class="token punctuation">}</span>
</code></pre> 
  <p><strong>在视图函数中</strong> -->可调用django中的reverse方法进行反向解析</p> 
  <pre><code class="prism language-powershell"><span class="token keyword">from</span> django<span class="token punctuation">.</span>urls import reverse
reverse<span class="token punctuation">(</span><span class="token string">'别名'</span><span class="token punctuation">,</span> args=<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span> kwargs=<span class="token punctuation">{
     </span><span class="token punctuation">}</span><span class="token punctuation">)</span>
ex:
print<span class="token punctuation">(</span>reverse<span class="token punctuation">(</span><span class="token string">'pagen'</span><span class="token punctuation">,</span>args=<span class="token punctuation">[</span>300<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
print<span class="token punctuation">(</span>reverse<span class="token punctuation">(</span><span class="token string">'person'</span><span class="token punctuation">,</span>kwargs=<span class="token punctuation">{
     </span><span class="token string">'name'</span>:<span class="token string">'xixi'</span><span class="token punctuation">,</span><span class="token string">'age'</span>:18<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
</code></pre> 
  <h1>祝大家学习python顺利!</h1> 
 </div> 
</div>
                            </div>
                        </div>
                    </div>
                    <!--PC和WAP自适应版-->
                    <div id="SOHUCS" sid="1444819927218302976"></div>
                    <script type="text/javascript" src="/views/front/js/chanyan.js"></script>
                    <!-- 文章页-底部 动态广告位 -->
                    <div class="youdao-fixed-ad" id="detail_ad_bottom"></div>
                </div>
                <div class="col-md-3">
                    <div class="row" id="ad">
                        <!-- 文章页-右侧1 动态广告位 -->
                        <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_1"> </div>
                        </div>
                        <!-- 文章页-右侧2 动态广告位 -->
                        <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_2"></div>
                        </div>
                        <!-- 文章页-右侧3 动态广告位 -->
                        <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(django,ubuntu,python,django,python,ubuntu,知识图谱)</h4>
        <div id="paradigm-article-related">
            <div class="recommend-post mb30">
                <ul class="widget-links">
                    <li><a href="/article/1835511912843014144.htm"
                           title="理解Gunicorn:Python WSGI服务器的基石" target="_blank">理解Gunicorn:Python WSGI服务器的基石</a>
                        <span class="text-muted">范范0825</span>
<a class="tag" taget="_blank" href="/search/ipython/1.htm">ipython</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a>
                        <div>理解Gunicorn:PythonWSGI服务器的基石介绍Gunicorn,全称GreenUnicorn,是一个为PythonWSGI(WebServerGatewayInterface)应用设计的高效、轻量级HTTP服务器。作为PythonWeb应用部署的常用工具,Gunicorn以其高性能和易用性著称。本文将介绍Gunicorn的基本概念、安装和配置,帮助初学者快速上手。1.什么是Gunico</div>
                    </li>
                    <li><a href="/article/1835506869838376960.htm"
                           title="Python数据分析与可视化实战指南" target="_blank">Python数据分析与可视化实战指南</a>
                        <span class="text-muted">William数据分析</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE/1.htm">数据</a>
                        <div>在数据驱动的时代,Python因其简洁的语法、强大的库生态系统以及活跃的社区,成为了数据分析与可视化的首选语言。本文将通过一个详细的案例,带领大家学习如何使用Python进行数据分析,并通过可视化来直观呈现分析结果。一、环境准备1.1安装必要库在开始数据分析和可视化之前,我们需要安装一些常用的库。主要包括pandas、numpy、matplotlib和seaborn等。这些库分别用于数据处理、数学</div>
                    </li>
                    <li><a href="/article/1835505858939809792.htm"
                           title="python os.environ" target="_blank">python os.environ</a>
                        <span class="text-muted">江湖偌大</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/1.htm">深度学习</a>
                        <div>os.environ['TF_CPP_MIN_LOG_LEVEL']='0'#默认值,输出所有信息os.environ['TF_CPP_MIN_LOG_LEVEL']='1'#屏蔽通知信息(INFO)os.environ['TF_CPP_MIN_LOG_LEVEL']='2'#屏蔽通知信息和警告信息(INFO\WARNING)os.environ['TF_CPP_MIN_LOG_LEVEL']='</div>
                    </li>
                    <li><a href="/article/1835505606245576704.htm"
                           title="Python中os.environ基本介绍及使用方法" target="_blank">Python中os.environ基本介绍及使用方法</a>
                        <span class="text-muted">鹤冲天Pro</span>
<a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>文章目录python中os.environos.environ简介os.environ进行环境变量的增删改查python中os.environ的使用详解1.简介2.key字段详解2.1常见key字段3.os.environ.get()用法4.环境变量的增删改查和判断是否存在4.1新增环境变量4.2更新环境变量4.3获取环境变量4.4删除环境变量4.5判断环境变量是否存在python中os.envi</div>
                    </li>
                    <li><a href="/article/1835505226933694464.htm"
                           title="Pyecharts数据可视化大屏:打造沉浸式数据分析体验" target="_blank">Pyecharts数据可视化大屏:打造沉浸式数据分析体验</a>
                        <span class="text-muted">我的运维人生</span>
<a class="tag" taget="_blank" href="/search/%E4%BF%A1%E6%81%AF%E5%8F%AF%E8%A7%86%E5%8C%96/1.htm">信息可视化</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98/1.htm">数据挖掘</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4%E5%BC%80%E5%8F%91/1.htm">运维开发</a><a class="tag" taget="_blank" href="/search/%E6%8A%80%E6%9C%AF%E5%85%B1%E4%BA%AB/1.htm">技术共享</a>
                        <div>Pyecharts数据可视化大屏:打造沉浸式数据分析体验在当今这个数据驱动的时代,如何将海量数据以直观、生动的方式展现出来,成为了数据分析师和企业决策者关注的焦点。Pyecharts,作为一款基于Python的开源数据可视化库,凭借其丰富的图表类型、灵活的配置选项以及高度的定制化能力,成为了构建数据可视化大屏的理想选择。本文将深入探讨如何利用Pyecharts打造数据可视化大屏,并通过实际代码案例</div>
                    </li>
                    <li><a href="/article/1835504217729626112.htm"
                           title="Python教程:一文了解使用Python处理XPath" target="_blank">Python教程:一文了解使用Python处理XPath</a>
                        <span class="text-muted">旦莫</span>
<a class="tag" taget="_blank" href="/search/Python%E8%BF%9B%E9%98%B6/1.htm">Python进阶</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>目录1.环境准备1.1安装lxml1.2验证安装2.XPath基础2.1什么是XPath?2.2XPath语法2.3示例XML文档3.使用lxml解析XML3.1解析XML文档3.2查看解析结果4.XPath查询4.1基本路径查询4.2使用属性查询4.3查询多个节点5.XPath的高级用法5.1使用逻辑运算符5.2使用函数6.实战案例6.1从网页抓取数据6.1.1安装Requests库6.1.2代</div>
                    </li>
                    <li><a href="/article/1835503965563875328.htm"
                           title="python os.environ_python os.environ 读取和设置环境变量" target="_blank">python os.environ_python os.environ 读取和设置环境变量</a>
                        <span class="text-muted">weixin_39605414</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/os.environ/1.htm">os.environ</a>
                        <div>>>>importos>>>os.environ.keys()['LC_NUMERIC','GOPATH','GOROOT','GOBIN','LESSOPEN','SSH_CLIENT','LOGNAME','USER','HOME','LC_PAPER','PATH','DISPLAY','LANG','TERM','SHELL','J2REDIR','LC_MONETARY','QT_QPA</div>
                    </li>
                    <li><a href="/article/1835497664922349568.htm"
                           title="使用Faiss进行高效相似度搜索" target="_blank">使用Faiss进行高效相似度搜索</a>
                        <span class="text-muted">llzwxh888</span>
<a class="tag" taget="_blank" href="/search/faiss/1.htm">faiss</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>在现代AI应用中,快速和高效的相似度搜索是至关重要的。Faiss(FacebookAISimilaritySearch)是一个专门用于快速相似度搜索和聚类的库,特别适用于高维向量。本文将介绍如何使用Faiss来进行相似度搜索,并结合Python代码演示其基本用法。什么是Faiss?Faiss是一个由FacebookAIResearch团队开发的开源库,主要用于高维向量的相似性搜索和聚类。Faiss</div>
                    </li>
                    <li><a href="/article/1835497665853485056.htm"
                           title="python是什么意思中文-在python中%是什么意思" target="_blank">python是什么意思中文-在python中%是什么意思</a>
                        <span class="text-muted">编程大乐趣</span>

                        <div>Python中%有两种:1、数值运算:%代表取模,返回除法的余数。如:>>>7%212、%操作符(字符串格式化,stringformatting),说明如下:%[(name)][flags][width].[precision]typecode(name)为命名flags可以有+,-,''或0。+表示右对齐。-表示左对齐。''为一个空格,表示在正数的左侧填充一个空格,从而与负数对齐。0表示使用0填</div>
                    </li>
                    <li><a href="/article/1835496780066811904.htm"
                           title="在一台Ubuntu计算机上构建Hyperledger Fabric网络" target="_blank">在一台Ubuntu计算机上构建Hyperledger Fabric网络</a>
                        <span class="text-muted">落叶无声9</span>
<a class="tag" taget="_blank" href="/search/%E5%8C%BA%E5%9D%97%E9%93%BE/1.htm">区块链</a><a class="tag" taget="_blank" href="/search/%E8%B6%85%E7%BA%A7%E8%B4%A6%E6%9C%AC/1.htm">超级账本</a><a class="tag" taget="_blank" href="/search/Hyperledger/1.htm">Hyperledger</a><a class="tag" taget="_blank" href="/search/fabric/1.htm">fabric</a><a class="tag" taget="_blank" href="/search/%E5%8C%BA%E5%9D%97%E9%93%BE/1.htm">区块链</a><a class="tag" taget="_blank" href="/search/ubuntu/1.htm">ubuntu</a><a class="tag" taget="_blank" href="/search/%E6%9E%84%E5%BB%BA/1.htm">构建</a><a class="tag" taget="_blank" href="/search/hyperledger/1.htm">hyperledger</a><a class="tag" taget="_blank" href="/search/fabric/1.htm">fabric</a>
                        <div>在一台Ubuntu计算机上构建HyperledgerFabric网络Hyperledgerfabric是一个开源的区块链应用程序平台,为开发基于区块链的应用程序提供了一个起点。当我们提到HyperledgerFabric网络时,我们指的是使用HyperledgerFabric的正在运行的系统。即使只使用最少数量的组件,部署Fabric网络也不是一件容易的事。Fabric社区创建了一个名为Cello</div>
                    </li>
                    <li><a href="/article/1835495644123459584.htm"
                           title="Day1笔记-Python简介&标识符和关键字&输入输出" target="_blank">Day1笔记-Python简介&标识符和关键字&输入输出</a>
                        <span class="text-muted">~在杰难逃~</span>
<a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98/1.htm">数据挖掘</a>
                        <div>大家好,从今天开始呢,杰哥开展一个新的专栏,当然,数据分析部分也会不定时更新的,这个新的专栏主要是讲解一些Python的基础语法和知识,帮助0基础的小伙伴入门和学习Python,感兴趣的小伙伴可以开始认真学习啦!一、Python简介【了解】1.计算机工作原理编程语言就是用来定义计算机程序的形式语言。我们通过编程语言来编写程序代码,再通过语言处理程序执行向计算机发送指令,让计算机完成对应的工作,编程</div>
                    </li>
                    <li><a href="/article/1835495517774245888.htm"
                           title="python八股文面试题分享及解析(1)" target="_blank">python八股文面试题分享及解析(1)</a>
                        <span class="text-muted">Shawn________</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>#1.'''a=1b=2不用中间变量交换a和b'''#1.a=1b=2a,b=b,aprint(a)print(b)结果:21#2.ll=[]foriinrange(3):ll.append({'num':i})print(11)结果:#[{'num':0},{'num':1},{'num':2}]#3.kk=[]a={'num':0}foriinrange(3):#0,12#可变类型,不仅仅改变</div>
                    </li>
                    <li><a href="/article/1835493753557708800.htm"
                           title="每日算法&面试题,大厂特训二十八天——第二十天(树)" target="_blank">每日算法&面试题,大厂特训二十八天——第二十天(树)</a>
                        <span class="text-muted">肥学</span>
<a class="tag" taget="_blank" href="/search/%E2%9A%A1%E7%AE%97%E6%B3%95%E9%A2%98%E2%9A%A1%E9%9D%A2%E8%AF%95%E9%A2%98%E6%AF%8F%E6%97%A5%E7%B2%BE%E8%BF%9B/1.htm">⚡算法题⚡面试题每日精进</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a>
                        <div>目录标题导读算法特训二十八天面试题点击直接资料领取导读肥友们为了更好的去帮助新同学适应算法和面试题,最近我们开始进行专项突击一步一步来。上一期我们完成了动态规划二十一天现在我们进行下一项对各类算法进行二十八天的一个小总结。还在等什么快来一起肥学进行二十八天挑战吧!!特别介绍小白练手专栏,适合刚入手的新人欢迎订阅编程小白进阶python有趣练手项目里面包括了像《机器人尬聊》《恶搞程序》这样的有趣文章</div>
                    </li>
                    <li><a href="/article/1835493626688401408.htm"
                           title="Python快速入门 —— 第三节:类与对象" target="_blank">Python快速入门 —— 第三节:类与对象</a>
                        <span class="text-muted">孤华暗香</span>
<a class="tag" taget="_blank" href="/search/Python%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/1.htm">Python快速入门</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>第三节:类与对象目标:了解面向对象编程的基础概念,并学会如何定义类和创建对象。内容:类与对象:定义类:class关键字。类的构造函数:__init__()。类的属性和方法。对象的创建与使用。示例:classStudent:def__init__(self,name,age,major):self.name&#</div>
                    </li>
                    <li><a href="/article/1835492869062881280.htm"
                           title="pyecharts——绘制柱形图折线图" target="_blank">pyecharts——绘制柱形图折线图</a>
                        <span class="text-muted">2224070247</span>
<a class="tag" taget="_blank" href="/search/%E4%BF%A1%E6%81%AF%E5%8F%AF%E8%A7%86%E5%8C%96/1.htm">信息可视化</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/1.htm">数据可视化</a>
                        <div>一、pyecharts概述自2013年6月百度EFE(ExcellentFrontEnd)数据可视化团队研发的ECharts1.0发布到GitHub网站以来,ECharts一直备受业界权威的关注并获得广泛好评,成为目前成熟且流行的数据可视化图表工具,被应用到诸多数据可视化的开发领域。Python作为数据分析领域最受欢迎的语言,也加入ECharts的使用行列,并研发出方便Python开发者使用的数据</div>
                    </li>
                    <li><a href="/article/1835491859351302144.htm"
                           title="Python 实现图片裁剪(附代码) | Python工具" target="_blank">Python 实现图片裁剪(附代码) | Python工具</a>
                        <span class="text-muted">剑客阿良_ALiang</span>

                        <div>前言本文提供将图片按照自定义尺寸进行裁剪的工具方法,一如既往的实用主义。环境依赖ffmpeg环境安装,可以参考我的另一篇文章:windowsffmpeg安装部署_阿良的博客-CSDN博客本文主要使用到的不是ffmpeg,而是ffprobe也在上面这篇文章中的zip包中。ffmpy安装:pipinstallffmpy-ihttps://pypi.douban.com/simple代码不废话了,上代码</div>
                    </li>
                    <li><a href="/article/1835491353451130880.htm"
                           title="【华为OD技术面试真题 - 技术面】- python八股文真题题库(4)" target="_blank">【华为OD技术面试真题 - 技术面】- python八股文真题题库(4)</a>
                        <span class="text-muted">算法大师</span>
<a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BAod/1.htm">华为od</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>华为OD面试真题精选专栏:华为OD面试真题精选目录:2024华为OD面试手撕代码真题目录以及八股文真题目录文章目录华为OD面试真题精选**1.Python中的`with`**用途和功能自动资源管理示例:文件操作上下文管理协议示例代码工作流程解析优点2.\_\_new\_\_和**\_\_init\_\_**区别__new____init__区别总结3.**切片(Slicing)操作**基本切片语法</div>
                    </li>
                    <li><a href="/article/1835490974911000576.htm"
                           title="python os 环境变量" target="_blank">python os 环境变量</a>
                        <span class="text-muted">CV矿工</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/numpy/1.htm">numpy</a>
                        <div>环境变量:环境变量是程序和操作系统之间的通信方式。有些字符不宜明文写进代码里,比如数据库密码,个人账户密码,如果写进自己本机的环境变量里,程序用的时候通过os.environ.get()取出来就行了。os.environ是一个环境变量的字典。环境变量的相关操作importos"""设置/修改环境变量:os.environ[‘环境变量名称’]=‘环境变量值’#其中key和value均为string类</div>
                    </li>
                    <li><a href="/article/1835490218845761536.htm"
                           title="Python爬虫解析工具之xpath使用详解" target="_blank">Python爬虫解析工具之xpath使用详解</a>
                        <span class="text-muted">eqa11</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E7%88%AC%E8%99%AB/1.htm">爬虫</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>文章目录Python爬虫解析工具之xpath使用详解一、引言二、环境准备1、插件安装2、依赖库安装三、xpath语法详解1、路径表达式2、通配符3、谓语4、常用函数四、xpath在Python代码中的使用1、文档树的创建2、使用xpath表达式3、获取元素内容和属性五、总结Python爬虫解析工具之xpath使用详解一、引言在Python爬虫开发中,数据提取是一个至关重要的环节。xpath作为一门</div>
                    </li>
                    <li><a href="/article/1835483915071090688.htm"
                           title="【华为OD技术面试真题 - 技术面】- python八股文真题题库(1)" target="_blank">【华为OD技术面试真题 - 技术面】- python八股文真题题库(1)</a>
                        <span class="text-muted">算法大师</span>
<a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BAod/1.htm">华为od</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>华为OD面试真题精选专栏:华为OD面试真题精选目录:2024华为OD面试手撕代码真题目录以及八股文真题目录文章目录华为OD面试真题精选1.数据预处理流程数据预处理的主要步骤工具和库2.介绍线性回归、逻辑回归模型线性回归(LinearRegression)模型形式:关键点:逻辑回归(LogisticRegression)模型形式:关键点:参数估计与评估:3.python浅拷贝及深拷贝浅拷贝(Shal</div>
                    </li>
                    <li><a href="/article/1835483159630802944.htm"
                           title="nosql数据库技术与应用知识点" target="_blank">nosql数据库技术与应用知识点</a>
                        <span class="text-muted">皆过客,揽星河</span>
<a class="tag" taget="_blank" href="/search/NoSQL/1.htm">NoSQL</a><a class="tag" taget="_blank" href="/search/nosql/1.htm">nosql</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a><a class="tag" taget="_blank" href="/search/%E9%9D%9E%E5%85%B3%E7%B3%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">非关系型数据库</a>
                        <div>Nosql知识回顾大数据处理流程数据采集(flume、爬虫、传感器)数据存储(本门课程NoSQL所处的阶段)Hdfs、MongoDB、HBase等数据清洗(入仓)Hive等数据处理、分析(Spark、Flink等)数据可视化数据挖掘、机器学习应用(Python、SparkMLlib等)大数据时代存储的挑战(三高)高并发(同一时间很多人访问)高扩展(要求随时根据需求扩展存储)高效率(要求读写速度快)</div>
                    </li>
                    <li><a href="/article/1835481269690003456.htm"
                           title="《Python数据分析实战终极指南》" target="_blank">《Python数据分析实战终极指南》</a>
                        <span class="text-muted">xjt921122</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>对于分析师来说,大家在学习Python数据分析的路上,多多少少都遇到过很多大坑**,有关于技能和思维的**:Excel已经没办法处理现有的数据量了,应该学Python吗?找了一大堆Python和Pandas的资料来学习,为什么自己动手就懵了?跟着比赛类公开数据分析案例练了很久,为什么当自己面对数据需求还是只会数据处理而没有分析思路?学了对比、细分、聚类分析,也会用PEST、波特五力这类分析法,为啥</div>
                    </li>
                    <li><a href="/article/1835480639814594560.htm"
                           title="在Ubuntu中编译含有JSON的文件出现报错" target="_blank">在Ubuntu中编译含有JSON的文件出现报错</a>
                        <span class="text-muted">芝麻糊76</span>
<a class="tag" taget="_blank" href="/search/Linux/1.htm">Linux</a><a class="tag" taget="_blank" href="/search/kill_bug/1.htm">kill_bug</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/ubuntu/1.htm">ubuntu</a><a class="tag" taget="_blank" href="/search/json/1.htm">json</a>
                        <div>在ubuntu中进行JSON相关学习的时候,我发现了一些小问题,决定与大家进行分享,减少踩坑时候出现不必要的时间耗费截取部分含有JSON部分的代码进行展示char*str="{\"title\":\"JSONExample\",\"author\":{\"name\":\"JohnDoe\",\"age\":35,\"isVerified\":true},\"tags\":[\"json\",\"</div>
                    </li>
                    <li><a href="/article/1835477362700021760.htm"
                           title="Python中深拷贝与浅拷贝的区别" target="_blank">Python中深拷贝与浅拷贝的区别</a>
                        <span class="text-muted">yuxiaoyu.</span>

                        <div>转自:http://blog.csdn.net/u014745194/article/details/70271868定义:在Python中对象的赋值其实就是对象的引用。当创建一个对象,把它赋值给另一个变量的时候,python并没有拷贝这个对象,只是拷贝了这个对象的引用而已。浅拷贝:拷贝了最外围的对象本身,内部的元素都只是拷贝了一个引用而已。也就是,把对象复制一遍,但是该对象中引用的其他对象我不复</div>
                    </li>
                    <li><a href="/article/1835476983614631936.htm"
                           title="Python开发常用的三方模块如下:" target="_blank">Python开发常用的三方模块如下:</a>
                        <span class="text-muted">换个网名有点难</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>Python是一门功能强大的编程语言,拥有丰富的第三方库,这些库为开发者提供了极大的便利。以下是100个常用的Python库,涵盖了多个领域:1、NumPy,用于科学计算的基础库。2、Pandas,提供数据结构和数据分析工具。3、Matplotlib,一个绘图库。4、Scikit-learn,机器学习库。5、SciPy,用于数学、科学和工程的库。6、TensorFlow,由Google开发的开源机</div>
                    </li>
                    <li><a href="/article/1835476350190841856.htm"
                           title="ExpRe[25] bash外的其它shell:zsh和fish" target="_blank">ExpRe[25] bash外的其它shell:zsh和fish</a>
                        <span class="text-muted">tritone</span>
<a class="tag" taget="_blank" href="/search/ExpRe/1.htm">ExpRe</a><a class="tag" taget="_blank" href="/search/bash/1.htm">bash</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/ubuntu/1.htm">ubuntu</a><a class="tag" taget="_blank" href="/search/shell/1.htm">shell</a>
                        <div>文章目录zsh基础配置实用特性插件`autojump`语法高亮自动补全fish优点缺点时效性本篇撰写时间为2021.12.15,由于计算机技术日新月异,博客中所有内容都有时效和版本限制,具体做法不一定总行得通,链接可能改动失效,各种软件的用法可能有修改。但是其中透露的思想往往是值得学习的。本篇前置:ExpRe[10]Ubuntu[2]准备神秘软件、备份恢复软件https://www.cnblogs</div>
                    </li>
                    <li><a href="/article/1835473704432267264.htm"
                           title="Python编译器" target="_blank">Python编译器</a>
                        <span class="text-muted">鹿鹿~</span>
<a class="tag" taget="_blank" href="/search/Python%E7%BC%96%E8%AF%91%E5%99%A8/1.htm">Python编译器</a><a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/%E5%90%8E%E7%AB%AF/1.htm">后端</a>
                        <div>嘿嘿嘿我又来了啊有些小盆友可能不知道Python其实是有编译器的,也就是PyCharm。你们可能会问到这个是干嘛的又不可以吃也不可以穿好像没有什么用,其实你还说对了这个还真的不可以吃也不可以穿,但是它用来干嘛的呢。用来编译你所打出的代码进行运行(可能这里说的有点不对但是只是个人认为)现在我们来说说PyCharm是用来干嘛的。PyCharm是一种PythonIDE,带有一整套可以帮助用户在使用Pyt</div>
                    </li>
                    <li><a href="/article/1835471437754888192.htm"
                           title="一文掌握python面向对象魔术方法(二)" target="_blank">一文掌握python面向对象魔术方法(二)</a>
                        <span class="text-muted">程序员neil</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>接上篇:一文掌握python面向对象魔术方法(一)-CSDN博客目录六、迭代和序列化:1、__iter__(self):定义迭代器,使得类可以被for循环迭代。2、__getitem__(self,key):定义索引操作,如obj[key]。3、__setitem__(self,key,value):定义赋值操作,如obj[key]=value。4、__delitem__(self,key):定义</div>
                    </li>
                    <li><a href="/article/1835471185589137408.htm"
                           title="一文掌握python常用的list(列表)操作" target="_blank">一文掌握python常用的list(列表)操作</a>
                        <span class="text-muted">程序员neil</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>目录一、创建列表1.直接创建列表:2.使用list()构造器3.使用列表推导式4.创建空列表二、访问列表元素1.列表支持通过索引访问元素,索引从0开始:2.还可以使用切片操作访问列表的一部分:三、修改列表元素四、添加元素1.append():在末尾添加元素2.insert():在指定位置插入元素五、删除元素1.del:删除指定位置的元素2.remove():删除指定值的第一个匹配项3.pop():</div>
                    </li>
                    <li><a href="/article/1835469798838988800.htm"
                           title="Python实现简单的机器学习算法" target="_blank">Python实现简单的机器学习算法</a>
                        <span class="text-muted">master_chenchengg</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%8A%9E%E5%85%AC%E6%95%88%E7%8E%87/1.htm">办公效率</a><a class="tag" taget="_blank" href="/search/python%E5%BC%80%E5%8F%91/1.htm">python开发</a><a class="tag" taget="_blank" href="/search/IT/1.htm">IT</a>
                        <div>Python实现简单的机器学习算法开篇:初探机器学习的奇妙之旅搭建环境:一切从安装开始必备工具箱第一步:安装Anaconda和JupyterNotebook小贴士:如何配置Python环境变量算法初体验:从零开始的Python机器学习线性回归:让数据说话数据准备:从哪里找数据编码实战:Python实现线性回归模型评估:如何判断模型好坏逻辑回归:从分类开始理论入门:什么是逻辑回归代码实现:使用skl</div>
                    </li>
                                <li><a href="/article/77.htm"
                                       title="算法 单链的创建与删除" target="_blank">算法 单链的创建与删除</a>
                                    <span class="text-muted">换个号韩国红果果</span>
<a class="tag" taget="_blank" href="/search/c/1.htm">c</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                                    <div>
先创建结构体
struct student {
	int data;
	//int tag;//标记这是第几个
	struct student *next;
};
//  addone 用于将一个数插入已从小到大排好序的链中
struct student *addone(struct student *h,int x){
		if(h==NULL)  //??????
			</div>
                                </li>
                                <li><a href="/article/204.htm"
                                       title="《大型网站系统与Java中间件实践》第2章读后感" target="_blank">《大型网站系统与Java中间件实践》第2章读后感</a>
                                    <span class="text-muted">白糖_</span>
<a class="tag" taget="_blank" href="/search/java%E4%B8%AD%E9%97%B4%E4%BB%B6/1.htm">java中间件</a>
                                    <div>       断断续续花了两天时间试读了《大型网站系统与Java中间件实践》的第2章,这章总述了从一个小型单机构建的网站发展到大型网站的演化过程---整个过程会遇到很多困难,但每一个屏障都会有解决方案,最终就是依靠这些个解决方案汇聚到一起组成了一个健壮稳定高效的大型系统。 
  
       看完整章内容,</div>
                                </li>
                                <li><a href="/article/331.htm"
                                       title="zeus持久层spring事务单元测试" target="_blank">zeus持久层spring事务单元测试</a>
                                    <span class="text-muted">deng520159</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/DAO/1.htm">DAO</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/jdbc/1.htm">jdbc</a>
                                    <div>今天把zeus事务单元测试放出来,让大家指出他的毛病, 
1.ZeusTransactionTest.java 单元测试 
  
package com.dengliang.zeus.webdemo.test;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;
import </div>
                                </li>
                                <li><a href="/article/458.htm"
                                       title="Rss 订阅 开发" target="_blank">Rss 订阅 开发</a>
                                    <span class="text-muted">周凡杨</span>
<a class="tag" taget="_blank" href="/search/html/1.htm">html</a><a class="tag" taget="_blank" href="/search/xml/1.htm">xml</a><a class="tag" taget="_blank" href="/search/%E8%AE%A2%E9%98%85/1.htm">订阅</a><a class="tag" taget="_blank" href="/search/rss/1.htm">rss</a><a class="tag" taget="_blank" href="/search/%E8%A7%84%E8%8C%83/1.htm">规范</a>
                                    <div>  
              RSS是 Really Simple Syndication的缩写(对rss2.0而言,是这三个词的缩写,对rss1.0而言则是RDF Site Summary的缩写,1.0与2.0走的是两个体系)。 
  
RSS</div>
                                </li>
                                <li><a href="/article/585.htm"
                                       title="分页查询实现" target="_blank">分页查询实现</a>
                                    <span class="text-muted">g21121</span>
<a class="tag" taget="_blank" href="/search/%E5%88%86%E9%A1%B5%E6%9F%A5%E8%AF%A2/1.htm">分页查询</a>
                                    <div>在查询列表时我们常常会用到分页,分页的好处就是减少数据交换,每次查询一定数量减少数据库压力等等。 
按实现形式分前台分页和服务器分页: 
前台分页就是一次查询出所有记录,在页面中用js进行虚拟分页,这种形式在数据量较小时优势比较明显,一次加载就不必再访问服务器了,但当数据量较大时会对页面造成压力,传输速度也会大幅下降。 
服务器分页就是每次请求相同数量记录,按一定规则排序,每次取一定序号直接的数据</div>
                                </li>
                                <li><a href="/article/712.htm"
                                       title="spring jms异步消息处理" target="_blank">spring jms异步消息处理</a>
                                    <span class="text-muted">510888780</span>
<a class="tag" taget="_blank" href="/search/jms/1.htm">jms</a>
                                    <div>spring JMS对于异步消息处理基本上只需配置下就能进行高效的处理。其核心就是消息侦听器容器,常用的类就是DefaultMessageListenerContainer。该容器可配置侦听器的并发数量,以及配合MessageListenerAdapter使用消息驱动POJO进行消息处理。且消息驱动POJO是放入TaskExecutor中进行处理,进一步提高性能,减少侦听器的阻塞。具体配置如下: </div>
                                </li>
                                <li><a href="/article/839.htm"
                                       title="highCharts柱状图" target="_blank">highCharts柱状图</a>
                                    <span class="text-muted">布衣凌宇</span>
<a class="tag" taget="_blank" href="/search/hightCharts/1.htm">hightCharts</a><a class="tag" taget="_blank" href="/search/%E6%9F%B1%E5%9B%BE/1.htm">柱图</a>
                                    <div>第一步:导入 exporting.js,grid.js,highcharts.js;第二步:写controller 
  
@Controller@RequestMapping(value="${adminPath}/statistick")public class StatistickController {  private UserServi</div>
                                </li>
                                <li><a href="/article/966.htm"
                                       title="我的spring学习笔记2-IoC(反向控制 依赖注入)" target="_blank">我的spring学习笔记2-IoC(反向控制 依赖注入)</a>
                                    <span class="text-muted">aijuans</span>
<a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/mvc/1.htm">mvc</a><a class="tag" taget="_blank" href="/search/Spring+%E6%95%99%E7%A8%8B/1.htm">Spring 教程</a><a class="tag" taget="_blank" href="/search/spring3+%E6%95%99%E7%A8%8B/1.htm">spring3 教程</a><a class="tag" taget="_blank" href="/search/Spring+%E5%85%A5%E9%97%A8/1.htm">Spring 入门</a>
                                    <div>IoC(反向控制 依赖注入)这是Spring提出来了,这也是Spring一大特色。这里我不用多说,我们看Spring教程就可以了解。当然我们不用Spring也可以用IoC,下面我将介绍不用Spring的IoC。 
IoC不是框架,她是java的技术,如今大多数轻量级的容器都会用到IoC技术。这里我就用一个例子来说明: 
如:程序中有 Mysql.calss 、Oracle.class 、SqlSe</div>
                                </li>
                                <li><a href="/article/1093.htm"
                                       title="TLS java简单实现" target="_blank">TLS java简单实现</a>
                                    <span class="text-muted">antlove</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/ssl/1.htm">ssl</a><a class="tag" taget="_blank" href="/search/keystore/1.htm">keystore</a><a class="tag" taget="_blank" href="/search/tls/1.htm">tls</a><a class="tag" taget="_blank" href="/search/secure/1.htm">secure</a>
                                    <div>  
1. SSLServer.java 
package ssl;

import java.io.FileInputStream;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.security.KeyStore;
import </div>
                                </li>
                                <li><a href="/article/1220.htm"
                                       title="Zip解压压缩文件" target="_blank">Zip解压压缩文件</a>
                                    <span class="text-muted">百合不是茶</span>
<a class="tag" taget="_blank" href="/search/Zip%E6%A0%BC%E5%BC%8F%E8%A7%A3%E5%8E%8B/1.htm">Zip格式解压</a><a class="tag" taget="_blank" href="/search/Zip%E6%B5%81%E7%9A%84%E4%BD%BF%E7%94%A8/1.htm">Zip流的使用</a><a class="tag" taget="_blank" href="/search/%E6%96%87%E4%BB%B6%E8%A7%A3%E5%8E%8B/1.htm">文件解压</a>
                                    <div>  
 ZIP文件的解压缩实质上就是从输入流中读取数据。Java.util.zip包提供了类ZipInputStream来读取ZIP文件,下面的代码段创建了一个输入流来读取ZIP格式的文件; 
ZipInputStream in = new ZipInputStream(new FileInputStream(zipFileName)); 
  
  
&n</div>
                                </li>
                                <li><a href="/article/1347.htm"
                                       title="underscore.js 学习(一)" target="_blank">underscore.js 学习(一)</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/underscore/1.htm">underscore</a>
                                    <div>        工作中需要用到underscore.js,发现这是一个包括了很多基本功能函数的js库,里面有很多实用的函数。而且它没有扩展 javascript的原生对象。主要涉及对Collection、Object、Array、Function的操作。       学</div>
                                </li>
                                <li><a href="/article/1474.htm"
                                       title="java jvm常用命令工具——jstatd命令(Java Statistics Monitoring Daemon)" target="_blank">java jvm常用命令工具——jstatd命令(Java Statistics Monitoring Daemon)</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/jvm/1.htm">jvm</a><a class="tag" taget="_blank" href="/search/jstatd/1.htm">jstatd</a>
                                    <div>1.介绍 
        jstatd是一个基于RMI(Remove Method Invocation)的服务程序,它用于监控基于HotSpot的JVM中资源的创建及销毁,并且提供了一个远程接口允许远程的监控工具连接到本地的JVM执行命令。 
        jstatd是基于RMI的,所以在运行jstatd的服务</div>
                                </li>
                                <li><a href="/article/1601.htm"
                                       title="【Spring框架三】Spring常用注解之Transactional" target="_blank">【Spring框架三】Spring常用注解之Transactional</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/transactional/1.htm">transactional</a>
                                    <div>Spring可以通过注解@Transactional来为业务逻辑层的方法(调用DAO完成持久化动作)添加事务能力,如下是@Transactional注解的定义: 
  
/*
 * Copyright 2002-2010 the original author or authors.
 *
 * Licensed under the Apache License, Version </div>
                                </li>
                                <li><a href="/article/1728.htm"
                                       title="我(程序员)的前进方向" target="_blank">我(程序员)的前进方向</a>
                                    <span class="text-muted">bitray</span>
<a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a>
                                    <div>作为一个普通的程序员,我一直游走在java语言中,java也确实让我有了很多的体会.不过随着学习的深入,java语言的新技术产生的越来越多,从最初期的javase,我逐渐开始转变到ssh,ssi,这种主流的码农,.过了几天为了解决新问题,webservice的大旗也被我祭出来了,又过了些日子jms架构的activemq也开始必须学习了.再后来开始了一系列技术学习,osgi,restful.....</div>
                                </li>
                                <li><a href="/article/1855.htm"
                                       title="nginx lua开发经验总结" target="_blank">nginx lua开发经验总结</a>
                                    <span class="text-muted">ronin47</span>

                                    <div>使用nginx lua已经两三个月了,项目接开发完毕了,这几天准备上线并且跟高德地图对接。回顾下来lua在项目中占得必中还是比较大的,跟PHP的占比差不多持平了,因此在开发中遇到一些问题备忘一下  1:content_by_lua中代码容量有限制,一般不要写太多代码,正常编写代码一般在100行左右(具体容量没有细心测哈哈,在4kb左右),如果超出了则重启nginx的时候会报 too long pa</div>
                                </li>
                                <li><a href="/article/1982.htm"
                                       title="java-66-用递归颠倒一个栈。例如输入栈{1,2,3,4,5},1在栈顶。颠倒之后的栈为{5,4,3,2,1},5处在栈顶" target="_blank">java-66-用递归颠倒一个栈。例如输入栈{1,2,3,4,5},1在栈顶。颠倒之后的栈为{5,4,3,2,1},5处在栈顶</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>
import java.util.Stack;

public class ReverseStackRecursive {

	/**
	 * Q 66.颠倒栈。
	 * 题目:用递归颠倒一个栈。例如输入栈{1,2,3,4,5},1在栈顶。
	 * 颠倒之后的栈为{5,4,3,2,1},5处在栈顶。
	 *1. Pop the top element
	 *2. Revers</div>
                                </li>
                                <li><a href="/article/2109.htm"
                                       title="正确理解Linux内存占用过高的问题" target="_blank">正确理解Linux内存占用过高的问题</a>
                                    <span class="text-muted">cfyme</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                                    <div>Linux开机后,使用top命令查看,4G物理内存发现已使用的多大3.2G,占用率高达80%以上: 
Mem:   3889836k total,  3341868k used,   547968k free,   286044k buffers 
Swap:  6127608k total,&nb</div>
                                </li>
                                <li><a href="/article/2236.htm"
                                       title="[JWFD开源工作流]当前流程引擎设计的一个急需解决的问题" target="_blank">[JWFD开源工作流]当前流程引擎设计的一个急需解决的问题</a>
                                    <span class="text-muted">comsci</span>
<a class="tag" taget="_blank" href="/search/%E5%B7%A5%E4%BD%9C%E6%B5%81/1.htm">工作流</a>
                                    <div> 
 
     当我们的流程引擎进入IRC阶段的时候,当循环反馈模型出现之后,每次循环都会导致一大堆节点内存数据残留在系统内存中,循环的次数越多,这些残留数据将导致系统内存溢出,并使得引擎崩溃。。。。。。 
 
      而解决办法就是利用汇编语言或者其它系统编程语言,在引擎运行时,把这些残留数据清除掉。</div>
                                </li>
                                <li><a href="/article/2363.htm"
                                       title="自定义类的equals函数" target="_blank">自定义类的equals函数</a>
                                    <span class="text-muted">dai_lm</span>
<a class="tag" taget="_blank" href="/search/equals/1.htm">equals</a>
                                    <div>仅作笔记使用 
 

public class VectorQueue {

	private final Vector<VectorItem> queue;

	private class VectorItem {
		private final Object item;
		private final int quantity;

		public VectorI</div>
                                </li>
                                <li><a href="/article/2490.htm"
                                       title="Linux下安装R语言" target="_blank">Linux下安装R语言</a>
                                    <span class="text-muted">datageek</span>
<a class="tag" taget="_blank" href="/search/R%E8%AF%AD%E8%A8%80+linux/1.htm">R语言 linux</a>
                                    <div>命令如下:sudo gedit  /etc/apt/sources.list1、deb http://mirrors.ustc.edu.cn/CRAN/bin/linux/ubuntu/ precise/ 2、deb http://dk.archive.ubuntu.com/ubuntu hardy universesudo apt-key adv --keyserver ke</div>
                                </li>
                                <li><a href="/article/2617.htm"
                                       title="如何修改mysql 并发数(连接数)最大值" target="_blank">如何修改mysql 并发数(连接数)最大值</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a>
                                    <div>MySQL的连接数最大值跟MySQL没关系,主要看系统和业务逻辑了 
  
方法一:进入MYSQL安装目录 打开MYSQL配置文件 my.ini 或 my.cnf查找 max_connections=100 修改为 max_connections=1000 服务里重起MYSQL即可 
  方法二:MySQL的最大连接数默认是100客户端登录:mysql -uusername -ppass</div>
                                </li>
                                <li><a href="/article/2744.htm"
                                       title="单一功能原则" target="_blank">单一功能原则</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E7%9A%84%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/1.htm">面向对象的程序设计</a><a class="tag" taget="_blank" href="/search/%E8%BD%AF%E4%BB%B6%E8%AE%BE%E8%AE%A1/1.htm">软件设计</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E5%8E%9F%E5%88%99/1.htm">编程原则</a>
                                    <div>单一功能原则[
编辑]            
SOLID    原则    
 
 单一功能原则 
 开闭原则 
 Liskov代换原则 
 接口隔离原则 
 依赖反转原则 
      
 
 查   
 论   
 编 
      
在面向对象编程领域中,单一功能原则(Single responsibility principle)规定每个类都应该有</div>
                                </li>
                                <li><a href="/article/2871.htm"
                                       title="POJO、VO和JavaBean区别和联系" target="_blank">POJO、VO和JavaBean区别和联系</a>
                                    <span class="text-muted">fanmingxing</span>
<a class="tag" taget="_blank" href="/search/VO/1.htm">VO</a><a class="tag" taget="_blank" href="/search/POJO/1.htm">POJO</a><a class="tag" taget="_blank" href="/search/javabean/1.htm">javabean</a>
                                    <div>POJO和JavaBean是我们常见的两个关键字,一般容易混淆,POJO全称是Plain Ordinary Java Object / Plain Old Java Object,中文可以翻译成:普通Java类,具有一部分getter/setter方法的那种类就可以称作POJO,但是JavaBean则比POJO复杂很多,JavaBean是一种组件技术,就好像你做了一个扳子,而这个扳子会在很多地方被</div>
                                </li>
                                <li><a href="/article/2998.htm"
                                       title="SpringSecurity3.X--LDAP:AD配置" target="_blank">SpringSecurity3.X--LDAP:AD配置</a>
                                    <span class="text-muted">hanqunfeng</span>
<a class="tag" taget="_blank" href="/search/SpringSecurity/1.htm">SpringSecurity</a>
                                    <div>前面介绍过基于本地数据库验证的方式,参考http://hanqunfeng.iteye.com/blog/1155226,这里说一下如何修改为使用AD进行身份验证【只对用户名和密码进行验证,权限依旧存储在本地数据库中】。 
  
将配置文件中的如下部分删除: 
  <!-- 认证管理器,使用自定义的UserDetailsService,并对密码采用md5加密-->  
  </div>
                                </li>
                                <li><a href="/article/3125.htm"
                                       title="mac mysql 修改密码" target="_blank">mac mysql 修改密码</a>
                                    <span class="text-muted">IXHONG</span>
<a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a>
                                    <div>$ sudo /usr/local/mysql/bin/mysqld_safe –user=root & //启动MySQL(也可以通过偏好设置面板来启动)$ sudo /usr/local/mysql/bin/mysqladmin -uroot password yourpassword //设置MySQL密码(注意,这是第一次MySQL密码为空的时候的设置命令,如果是修改密码,还需在-</div>
                                </li>
                                <li><a href="/article/3252.htm"
                                       title="设计模式--抽象工厂模式" target="_blank">设计模式--抽象工厂模式</a>
                                    <span class="text-muted">kerryg</span>
<a class="tag" taget="_blank" href="/search/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/1.htm">设计模式</a>
                                    <div>抽象工厂模式: 
 
    工厂模式有一个问题就是,类的创建依赖于工厂类,也就是说,如果想要拓展程序,必须对工厂类进行修改,这违背了闭包原则。我们采用抽象工厂模式,创建多个工厂类,这样一旦需要增加新的功能,直接增加新的工厂类就可以了,不需要修改之前的代码。 
 
    总结:这个模式的好处就是,如果想增加一个功能,就需要做一个实现类,</div>
                                </li>
                                <li><a href="/article/3379.htm"
                                       title="评"高中女生军训期跳楼”" target="_blank">评"高中女生军训期跳楼”</a>
                                    <span class="text-muted">nannan408</span>

                                    <div>   首先,先抛出我的观点,各位看官少点砖头。那就是,中国的差异化教育必须做起来。 
   孔圣人有云:有教无类。不同类型的人,都应该有对应的教育方法。目前中国的一体化教育,不知道已经扼杀了多少创造性人才。我们出不了爱迪生,出不了爱因斯坦,很大原因,是我们的培养思路错了,我们是第一要“顺从”。如果不顺从,我们的学校,就会用各种方法,罚站,罚写作业,各种罚。军</div>
                                </li>
                                <li><a href="/article/3506.htm"
                                       title="scala如何读取和写入文件内容?" target="_blank">scala如何读取和写入文件内容?</a>
                                    <span class="text-muted">qindongliang1922</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/jvm/1.htm">jvm</a><a class="tag" taget="_blank" href="/search/scala/1.htm">scala</a>
                                    <div>直接看如下代码: 
 
package file

import java.io.RandomAccessFile
import java.nio.charset.Charset

import scala.io.Source
import scala.reflect.io.{File, Path}

/**
 * Created by qindongliang on 2015/</div>
                                </li>
                                <li><a href="/article/3633.htm"
                                       title="C语言算法之百元买百鸡" target="_blank">C语言算法之百元买百鸡</a>
                                    <span class="text-muted">qiufeihu</span>
<a class="tag" taget="_blank" href="/search/c/1.htm">c</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                                    <div>中国古代数学家张丘建在他的《算经》中提出了一个著名的“百钱买百鸡问题”,鸡翁一,值钱五,鸡母一,值钱三,鸡雏三,值钱一,百钱买百鸡,问翁,母,雏各几何? 
代码如下: 
#include <stdio.h>
int main()
{
	int cock,hen,chick;                               /*定义变量为基本整型*/
	for(coc</div>
                                </li>
                                <li><a href="/article/3760.htm"
                                       title="Hadoop集群安全性:Hadoop中Namenode单点故障的解决方案及详细介绍AvatarNode" target="_blank">Hadoop集群安全性:Hadoop中Namenode单点故障的解决方案及详细介绍AvatarNode</a>
                                    <span class="text-muted">wyz2009107220</span>
<a class="tag" taget="_blank" href="/search/NameNode/1.htm">NameNode</a>
                                    <div>正如大家所知,NameNode在Hadoop系统中存在单点故障问题,这个对于标榜高可用性的Hadoop来说一直是个软肋。本文讨论一下为了解决这个问题而存在的几个solution。 
1. Secondary NameNode 
原理:Secondary NN会定期的从NN中读取editlog,与自己存储的Image进行合并形成新的metadata image 
优点:Hadoop较早的版本都自带,</div>
                                </li>
                </ul>
            </div>
        </div>
    </div>

<div>
    <div class="container">
        <div class="indexes">
            <strong>按字母分类:</strong>
            <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a
                href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a
                href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a
                href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a
                href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a
                href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a
                href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a
                href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a
                href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a>
        </div>
    </div>
</div>
<footer id="footer" class="mb30 mt30">
    <div class="container">
        <div class="footBglm">
            <a target="_blank" href="/">首页</a> -
            <a target="_blank" href="/custom/about.htm">关于我们</a> -
            <a target="_blank" href="/search/Java/1.htm">站内搜索</a> -
            <a target="_blank" href="/sitemap.txt">Sitemap</a> -
            <a target="_blank" href="/custom/delete.htm">侵权投诉</a>
        </div>
        <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved.
<!--            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>-->
        </div>
    </div>
</footer>
<!-- 代码高亮 -->
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script>
<link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script>





</body>

</html>