1、权限的概念;

2、RBAC的设计;

3、注册登录用户所有权限到session中;

4、权限的校验;

5、基于中间件的权限校验;

1、权限的概念;

1.1 项目与应用;

  • Project
  • App

1.2 什么是权限?一个URL就是一个权限;

  1.2.1 who what how  <------>True or False

  1.2.2 表相关,如UserInfo、Permission、UserInfo_Permission;

  1.2.3 管理员权限,比如腾旭视频的VIP会员,这个世界上权限无处不在;

  1.2.4 应用范围最广泛;

  1.2.5 Who、What、How------>True Or Flase

2、RBAC的设计;

2.1 不同的角色设置不同的权限;

2.2 新增一张Role(角色表);

  • UserInfo
  • Role
  • Permission

2.3 rbac(Role base access control)

3、注册登录用户所有权限到session中;

3.1 基于rbac/models.py生成关系表;

from django.db import models

# Create your models here.

class User(models.Model):
name = models.CharField(max_length=32)
pwd = models.CharField(max_length=32)
roles = models.ManyToManyField(to="Role") def __str__(self):
return self.name class Role(models.Model):
title = models.CharField(max_length=32)
permissions = models.ManyToManyField(to="Permission") def __str__(self):
return self.title class Permission(models.Model):
title = models.CharField(max_length=32)
url = models.CharField(max_length=32) def __str__(self):
return self.title

2、进行数据库迁移操作;

python manage.py makemigrations
python migrate

3、在rbac/admin.py中进行register注册操作;

from django.contrib import admin

# Register your models here.
from .models import * admin.site.register(User)
admin.site.register(Role)
admin.site.register(Permission)

4、进行超级用户的创建cuixiaozhao;

Microsoft Windows [版本 10.0.17134.1]
(c) 2018 Microsoft Corporation。保留所有权利。 (venv) C:\Users\TQTL911\PycharmProjects\s9day82_rbac>python manage.py startapp rbac (venv) C:\Users\TQTL911\PycharmProjects\s9day82_rbac>python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\management\base.py", line 350, in execute
self.check()
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\management\base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\urls\resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\venv\lib\site-packages\django\urls\resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\s9day82_rbac\urls.py", line 18, in <module>
from app01 import views
File "C:\Users\TQTL911\PycharmProjects\s9day82_rbac\app01\views.py", line 5
user_id = request.
^
SyntaxError: invalid syntax (venv) C:\Users\TQTL911\PycharmProjects\s9day82_rbac>python manage.py makemigrations
Migrations for 'app01':
app01\migrations\0001_initial.py
- Create model User
Migrations for 'rbac':
rbac\migrations\0001_initial.py
- Create model Permission
- Create model Role
- Create model User (venv) C:\Users\TQTL911\PycharmProjects\s9day82_rbac>python manage.py migrate
Operations to perform:
Apply all migrations: admin, app01, auth, contenttypes, rbac, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying app01.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying rbac.0001_initial... OK
Applying sessions.0001_initial... OK (venv) C:\Users\TQTL911\PycharmProjects\s9day82_rbac>python manage.py createsuperuser
Username (leave blank to use 'tqtl911'): cuixiaozhao
Email address: tqtl@tqtl.org
Password:
Password (again):
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully. (venv) C:\Users\TQTL911\PycharmProjects\s9day82_rbac>

5、启动Django项目,进行admin后台访问;

6、分别通过前端页面,进行Permission、Role、User的添加操作;

7、在settings.py中添加INSTALLED_APPS并配置urls.py;

"""s9day82_rbac URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from app01 import views urlpatterns = [
path('admin/', admin.site.urls),
path('users/', views.users),
path('^/users/add', views.add_user),
path('^roles/', views.roles),
path('login/', views.login),
]

8、编写视图函数views.py;

from django.shortcuts import render, HttpResponse

# Create your views here.

from rbac.models import *

def users(request):
user_list = User.objects.all()
return render(request, "users.html", locals()) def add_user(request):
return HttpResponse("add_user") def roles(request):
user_list = User.objects.all()
return render(request, "users.html", locals()) def login(request):
if request.method == "POST":
user = request.POST.get("user")
pwd = request.POST.get("pwd")
user_obj = User.objects.filter(name=user, pwd=pwd).first()
if user_obj:
# 在session中注册用户的ID;
request.session["user_id"] = user.pk '''
在session中注册权限列表;
'''
# #查询当前登录用的所有角色;
# ret = user_obj.roles.all()
# print(ret)#<QuerySet [<Role: 保洁>, <Role: 销售>]>
# 查询当前登录用的所有权限; # ret = user_obj.roles.all().values("title")
# ret = user_obj.roles.all().values("title",
# "permissions__url") # <QuerySet [{'title': '保洁', 'permissions__url': '/users/'}, {'title': '销售', 'permissions__url': '/users/'}, {'title': '销售', 'permissions__url': '/users/add'}]> permissions = user_obj.roles.all().values(
"permissions__url").distinct() # <QuerySet [{'permissions__url': '/users/'}, {'permissions__url': '/users/add'}]>
permission_list = [] # 定义一个空列表;
for item in permissions:
permission_list.append(item["permissions__url"])
print(permission_list) # ['/users/', '/users/add']
request.session["permission_list"] = permission_list
'''
values:
temp = []
for role in user.roles.all(): #[<Role:保洁>,<Role:销售>]
temp.append({
"title":role.title,#<QuerySet [{'title': '保洁'}, {'title': '销售'}]>
})
'''
return HttpResponse("登录成功!") return render(request, "login.html")

9、编写templates下的login.html;

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css"> </style>
</head>
<body>
<h4>登录页面</h4>
<form action="" method="post">
{% csrf_token %}
用户名: <input type="text" name="user"></input>
密码: <input type="password" name="pwd"></input>
<input type="submit">
</form>
</body>
</html>

users.html;

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css"> </style>
</head>
<body>
<ul>
<h4>用户列表</h4>
{% for user in user_list %}
<p>{{ user }}</p>
{% endfor %} </ul>
</body>
</html>

4、权限的校验;

1、一个含有正则表达式的URL就是一个权限;

2、permission = “^%s$”%permission;

urls.py;

"""s9day82_rbac URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from app01 import views urlpatterns = [
path('admin/', admin.site.urls),
path('users/', views.users),
path('users/add', views.add_user),
path('roles/', views.roles),
path('login/', views.login),
]

views.py;

from django.shortcuts import render, HttpResponse

# Create your views here.

from rbac.models import *

def users(request):
user_list = User.objects.all()
return render(request, "users.html", locals()) def add_user(request):
permission_list = request.session[
"permission_list"] # ['/users/', '/users/add', '/users/delete/(\\d+)', 'users/edit(\\d+)']
current_path = request.path_info
if current_path in permission_list:
pass return HttpResponse("add_user") def roles(request):
user_list = User.objects.all()
return render(request, "users.html", locals()) def login(request):
if request.method == "POST":
user = request.POST.get("user")
pwd = request.POST.get("pwd")
user_obj = User.objects.filter(name=user, pwd=pwd).first()
if user_obj:
# 在session中注册用户的ID;
request.session["user_id"] = user_obj.pk '''
在session中注册权限列表;
'''
# #查询当前登录用的所有角色;
# ret = user_obj.roles.all()
# print(ret)#<QuerySet [<Role: 保洁>, <Role: 销售>]>
# 查询当前登录用的所有权限; # ret = user_obj.roles.all().values("title")
# ret = user_obj.roles.all().values("title",
# "permissions__url") # <QuerySet [{'title': '保洁', 'permissions__url': '/users/'}, {'title': '销售', 'permissions__url': '/users/'}, {'title': '销售', 'permissions__url': '/users/add'}]> permissions = user_obj.roles.all().values(
"permissions__url").distinct() # <QuerySet [{'permissions__url': '/users/'}, {'permissions__url': '/users/add'}]>
permission_list = [] # 定义一个空列表;
for item in permissions:
permission_list.append(item["permissions__url"])
print(permission_list) # ['/users/', '/users/add']
request.session["permission_list"] = permission_list
'''
values:
temp = []
for role in user.roles.all(): #[<Role:保洁>,<Role:销售>]
temp.append({
"title":role.title,#<QuerySet [{'title': '保洁'}, {'title': '销售'}]>
})
'''
return HttpResponse("登录成功!") return render(request, "login.html")

test.py;

from django.test import TestCase

# Create your tests here.

l = ['/users/', '/users/add', '/users/delete/(\\d+)', 'users/edit(\\d+)']
c_path = "users/delete/9" import re flag = False
for permission in l:
permission = "^%s$"%permission
ret = re.match("", c_path)
if ret:
flag = True
break
if flag:
print("Success!")

5、基于中间件的权限校验;

1、创建表关系:

2、基于admin录入数据;

3、 登录校验:

4、校验权限(中间件的应用)

5、自定义中间件,并在settings.py中配置;

6、配置白名单valid_url_list;

settings.py;

"""
Django settings for s9day82_rbac project. Generated by 'django-admin startproject' using Django 2.1. For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/ For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
""" import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'lp7xgai1mm6&w^!2jj3gj6j*fd)0^%nzks)w4t$a89s@c&zwt_' # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app01.apps.App01Config',
'rbac.apps.RbacConfig',
] 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',
'rbac.service.rbac.ValidPermission',
] ROOT_URLCONF = 's9day82_rbac.urls' TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
] WSGI_APPLICATION = 's9day82_rbac.wsgi.application' # Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
} # Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
] # Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/'

models.py;

from django.db import models

# Create your models here.

class User(models.Model):
name = models.CharField(max_length=32)
pwd = models.CharField(max_length=32)
roles = models.ManyToManyField(to="Role") def __str__(self):
return self.name class Role(models.Model):
title = models.CharField(max_length=32)
permissions = models.ManyToManyField(to="Permission") def __str__(self):
return self.title class Permission(models.Model):
title = models.CharField(max_length=32)
url = models.CharField(max_length=32) def __str__(self):
return self.title

urls.py;

"""s9day82_rbac URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from app01 import views urlpatterns = [
path('admin/', admin.site.urls),
path('users/', views.users),
path('users/add', views.add_user),
path('roles/', views.roles),
path('login/', views.login),
]

views.py;

from django.shortcuts import render, HttpResponse

# Create your views here.

from rbac.models import *
from rbac.service.permissions import *
import re def users(request):
user_list = User.objects.all()
return render(request, "users.html", locals()) def add_user(request): return HttpResponse("add_user") def roles(request):
#写个中间件; role_list = Role.objects.all()
return render(request, "roles.html", locals()) def login(request):
if request.method == "POST":
user = request.POST.get("user")
pwd = request.POST.get("pwd")
user_obj = User.objects.filter(name=user, pwd=pwd).first()
if user_obj:
# 在session中注册用户的ID;
request.session["user_id"] = user_obj.pk '''
在session中注册权限列表;
'''
# #查询当前登录用的所有角色;
# ret = user_obj.roles.all()
# print(ret)#<QuerySet [<Role: 保洁>, <Role: 销售>]>
# 查询当前登录用的所有权限; # ret = user_obj.roles.all().values("title")
# ret = user_obj.roles.all().values("title",
# "permissions__url") # <QuerySet [{'title': '保洁', 'permissions__url': '/users/'}, {'title': '销售', 'permissions__url': '/users/'}, {'title': '销售', 'permissions__url': '/users/add'}]> #查询当前登录用户的所有权限;
initial_session(user_obj,request)
'''
values:
temp = []
for role in user.roles.all(): #[<Role:保洁>,<Role:销售>]
temp.append({
"title":role.title,#<QuerySet [{'title': '保洁'}, {'title': '销售'}]>
})
'''
return HttpResponse("登录成功!") return render(request, "login.html")

permissions.py;

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# __Author__:TQTL911
# Version:python3.6.6
# Time:2018/8/29 22:28 def initial_session(user_obj,request):
permissions = user_obj.roles.all().values(
"permissions__url").distinct() # <QuerySet [{'permissions__url': '/users/'}, {'permissions__url': '/users/add'}]>
permission_list = [] # 定义一个空列表;
for item in permissions:
permission_list.append(item["permissions__url"])
print(permission_list) # ['/users/', '/users/add']
request.session["permission_list"] = permission_list

rbac.py;

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# __Author__:TQTL911
# Version:python3.6.6
# Time:2018/8/29 22:03
from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import HttpResponse, redirect
import re class ValidPermission(MiddlewareMixin):
def process_request(self, request):
# 当前访问的路径;
current_path = request.path_info
# 校验权限,检查是否属于白名单;
varlid_url_list = ["/login/", "/reg/", "/admin/.*"]
for valid_url in varlid_url_list:
ret = re.match(valid_url, current_path)
if ret:
return None
# 校验是否登录;
user_id = request.session.get("user_id")
if not user_id:
return redirect("/login/") if current_path in varlid_url_list:
return None # 权限的校验;
permission_list = request.session.get("permission_list",
[]) # ['/users/', '/users/add', '/users/delete/(\\d+)', 'users/edit(\\d+)']
flag = False
for permission in permission_list:
permission = "^%s$" % permission
ret = re.match(permission, current_path)
if ret:
flag = True
break
if not flag:
return HttpResponse("没有访问权限")
return None

tests.py;

from django.test import TestCase

# Create your tests here.

l = ['/users/', '/users/add', '/users/delete/(\\d+)', 'users/edit(\\d+)']
c_path = "users/delete/9" import re flag = False
for permission in l:
permission = "^%s$"%permission
ret = re.match("", c_path)
if ret:
flag = True
break
if flag:
print("Success!")

users.html;

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css"> </style>
</head>
<body>
<ul>
<h4>用户列表</h4>
{% for user in user_list %}
<p>{{ user }}</p>
{% endfor %} </ul>
</body>
</html>

roles.html;

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>roles</title>
<style type="text/css"> </style>
</head>
<body>
<ul>
<h4>角色列表</h4>
{% for role in role_list %}
<p>{{ role }}</p>
{% endfor %} </ul>
</body>
</html> 

5 权限按钮控制的简单形式;

5.1

6 权限菜单显示

7 Django的路径自动添加问题

7.1 settings.py中添加APPEND_SLASH = FALSE,默认为True,解决URL末尾路径斜杠自动添加的问题;

8 原生form实现增删改查

9 modelform实现增删改查

Python-S9——Day82-CRM项目实战的更多相关文章

  1. Python爬虫开发与项目实战

    Python爬虫开发与项目实战(高清版)PDF 百度网盘 链接:https://pan.baidu.com/s/1MFexF6S4No_FtC5U2GCKqQ 提取码:gtz1 复制这段内容后打开百度 ...

  2. Python爬虫开发与项目实战pdf电子书|网盘链接带提取码直接提取|

    Python爬虫开发与项目实战从基本的爬虫原理开始讲解,通过介绍Pthyon编程语言与HTML基础知识引领读者入门,之后根据当前风起云涌的云计算.大数据热潮,重点讲述了云计算的相关内容及其在爬虫中的应 ...

  3. python工业互联网监控项目实战5—Collector到opcua服务

    本小节演示项目是如何从连接器到获取Tank4C9服务上的设备对象的值,并通过Connector服务的url返回给UI端请求的.另外,实际项目中考虑websocket中间可能因为网络通信等原因出现中断情 ...

  4. python工业互联网监控项目实战4—python opcua

    前面章节我们采用OPC作为设备到上位的信息交互的协议,本章我们介绍跨平台的OPC UA.OPC作为早期的工业通信规范,是基于COM/DCOM的技术实现的,用于设备和软件之间交换数据,最初,OPC标准仅 ...

  5. python金融反欺诈-项目实战

    python信用评分卡(附代码,博主录制) https://study.163.com/course/introduction.htm?courseId=1005214003&utm_camp ...

  6. python工业互联网监控项目实战2—OPC

    OPC(OLE for Process Control)定义:指为了给工业控制系统应用程序之间的通信建立一个接口标准,在工业控制设备与控制软件之间建立统一的数据存取规范.它给工业控制领域提供了一种标准 ...

  7. python数据分析美国大选项目实战(三)

    项目介绍 项目地址:https://www.kaggle.com/fivethirtyeight/2016-election-polls 包含了2015年11月至2016年11月期间对于2016美国大 ...

  8. Python工业互联网监控项目实战3—websocket to UI

    本小节继续演示如何在Django项目中采用早期websocket技术原型来实现把OPC服务端数据实时推送到UI端,让监控页面在另一种技术方式下,实时显示现场设备的工艺数据变化情况.本例我们仍然采用比较 ...

  9. Python轻松入门到项目实战-实用教程

    本课程完全基于Python3讲解,针对广大的Python爱好者与同学录制.通过本课程的学习,可以让同学们在学习Python的过程中少走弯路.整个课程以实例教学为核心,通过对大量丰富的经典实例的讲解.让 ...

  10. 机器学习_线性回归和逻辑回归_案例实战:Python实现逻辑回归与梯度下降策略_项目实战:使用逻辑回归判断信用卡欺诈检测

    线性回归: 注:为偏置项,这一项的x的值假设为[1,1,1,1,1....] 注:为使似然函数越大,则需要最小二乘法函数越小越好 线性回归中为什么选用平方和作为误差函数?假设模型结果与测量值 误差满足 ...

随机推荐

  1. 【题解】洛谷P1311 [NOIP2011TG] 选择客栈(递推)

    题目来源:洛谷P1311 思路 纯暴力明显过不了这道题 所以我们要考虑如何优化到至多只能到nlogn 但是我们发现可以更优到O(n) 我们假设我们当前寻找的是第二个人住的客栈i 那么第一个人住的客栈肯 ...

  2. BindingException: Invalid bound statement (not found)问题排查:SpringBoot集成Mybatis重点分析

    重构代码,方法抛出异常:BindingException: Invalid bound statement (not found) 提示信息很明显:mybatis没有提供某方法 先不解释问题原因和排查 ...

  3. springBoot+mybatisPlus小demo

    项目介绍:采用restful api进行接口规范 / 项目框架SpringBoot+mybatis Plus / 采用mysql进行数据存储 / 采用swaggerUI进行前后端业务分离式开发. 开发 ...

  4. Oracle记录类型(record)和%rowtype

    Oracle中的记录类型(record)和使用%rowtype定义的数据类型都是一种单行多列的数据结构,可以理解为一个具有多个属性的对象.其中属性名即为列名. 记录类型(record) 记录类型是一种 ...

  5. Mac连接Linux服务器

    1.终端命令 a).打开Mac的命令终端 b).输入ssh -p 22 root@101.200.86.233 它会提示你输入密码,输入正确的密码之后,你就发现已经登陆成功了.(22: 端口号 roo ...

  6. 【若泽大数据实战第二天】Linux命令基础

    Linux基本命令: 查看IP: ifconfig 或者 hostname -i(需要配置文件之后才可以使用) ipconfig(Windows) 关闭防火墙: Service iptables st ...

  7. shell脚本实现目录的“5S”作业

    shell,又称为命令解释器.首先它是一个软件,有很多个版本,现在最流行的为bash,它作为用户和内核沟通的中间桥梁,在系统中起着举足轻重的作用 shell脚本,是一个以.sh结尾的文件,里面是诸如l ...

  8. 用原生JS写一个网页版的2048小游戏(兼容移动端)

    这个游戏JS部分全都是用原生JS代码写的,加有少量的CSS3动画,并简单的兼容了一下移动端. 先看一下在线的demo:https://yuan-yiming.github.io/2048-online ...

  9. Hbase 表的Rowkey设计避免数据热点

    一.案例分析 常见避免数据热点问题的处理方式有:加盐.哈希.反转等方法结合预分区使用. 由于目前原数据第一字段为时间戳形式,第二字段为电话号码,直接存储容易引起热点问题,通过加随机列.组合时间戳.字段 ...

  10. C语言之二叉树

    规定:根节点的值大于左节点但小于右节点的值,所以二叉树的值插入是唯一的,最后形成的树只跟根节点有关 定义节点: struct tree_node {      TypeElem  elem; stru ...