1.1 djangorestframework登录、认证和权限

  1、认证与权限相关模块

      

# -*- coding: utf-8 -*-
from django.utils import six
from rest_framework.response import Response
from rest_framework.serializers import Serializer class JsonResponse(Response):
"""
An HttpResponse that allows its data to be rendered into
arbitrary media types.
""" def __init__(self,
data=None,
code=None,
desc=None,
status=None,
template_name=None,
headers=None,
exception=False,
content_type='application/json; charset=utf-8'):
"""
Alters the init arguments slightly.
For example, drop 'template_name', and instead use 'data'.
Setting 'renderer' and 'media_type' will typically be deferred,
For example being set automatically by the `APIView`.
""" super(Response, self).__init__(None, status=status) if isinstance(data, Serializer):
msg = ('You passed a Serializer instance as data, but '
'probably meant to pass serialized `.data` or '
'`.error`. representation.')
raise AssertionError(msg) self.data = {"code": code, "desc": desc, "data": data}
self.template_name = template_name
self.exception = exception
self.content_type = content_type if headers:
for name, value in six.iteritems(headers):
self[name] = value

common\api_response.py 返回统一标准json数据

# -*- coding:utf-8 -*-
from __future__ import absolute_import from rest_framework import status as http_status
from common.api_response import JsonResponse __all__ = ['created_success'] def ajax_data(data=None,
code=http_status.HTTP_200_OK,
desc=None,
status=http_status.HTTP_200_OK): return JsonResponse(data=data, code=code, desc=desc, status=status) def success(data=None, desc=None):
return ajax_data(data=data, desc=desc) def error(data=None, desc=None):
return ajax_data(
data=data, code=http_status.HTTP_500_INTERNAL_SERVER_ERROR, desc=desc) def created_success(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_201_CREATED,
desc=desc,
status=http_status.HTTP_201_CREATED) def conflict(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_409_CONFLICT,
desc=desc,
status=http_status.HTTP_409_CONFLICT) def accepted(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_202_ACCEPTED,
desc=desc,
status=http_status.HTTP_202_ACCEPTED) def not_implemented(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_501_NOT_IMPLEMENTED,
desc=desc,
status=http_status.HTTP_501_NOT_IMPLEMENTED) def unauthorized(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_401_UNAUTHORIZED,
desc=desc,
status=http_status.HTTP_401_UNAUTHORIZED) def not_found(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_404_NOT_FOUND,
desc=desc,
status=http_status.HTTP_404_NOT_FOUND) def bad_request(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_400_BAD_REQUEST,
desc=desc,
status=http_status.HTTP_400_BAD_REQUEST)

common\ajax.py 将所有返回封装成标准状态码格式

#!/usr/bin/python
# -*- coding: utf-8 -*-
from rest_framework.views import APIView
from common.auth.authentication import IsAuthenticated, IsOwnerOrReadOnly class BaseViews(APIView):
authentication_classes = (IsAuthenticated,)
permission_classes = (IsOwnerOrReadOnly,) def __init__(self):
super(BaseViews).__init__(BaseViews, self)
self.user = None def perform_authentication(self, request):
self.user = self.get_authenticators()[0].authenticate(request).user

common\auth\base_views.py 自定义认证和权限的基类

#!/usr/bin/python
# -*- coding: utf-8 -*-
from rest_framework import exceptions
from rest_framework import authentication
from rest_framework import permissions
from users.models import VueUserToken class IsAuthenticated(authentication.BaseAuthentication):
"""
Custom permission to only allow owners of an object to edit it.
""" def authenticate(self, request):
auth = request.META.get('HTTP_AUTHORIZATION', None)
if auth is None:
raise exceptions.NotAuthenticated()
token = VueUserToken.objects.filter(key=auth)
try:
request.user = token[0].user
except IndexError:
raise exceptions.NotAuthenticated('Invalid input Authenticated')
return request def authenticate_header(self, request):
msg = 'Invalid token.Please get token first'
return exceptions.NotAuthenticated(msg) class IsOwnerOrReadOnly(permissions.BasePermission):
"""
是否有操作权限: 只有返回True才有操作权限,
""" def has_permission(self, request, view): if False: # 这里暂且不进行权限验证
raise exceptions.ParseError('您没有操作的权限')
return True

common\auth\authentication.py 验证token是否合法,是否有请求操作权限

#! /usr/bin/env python
# -*- coding: utf-8 -*-
import uuid
import hmac
from django.contrib.auth.models import User
from users.models import VueUserToken
from django.utils import timezone def create_token():
key = str(uuid.uuid1())
h = hmac.new(b"", key.encode(encoding="utf-8"))
return h.hexdigest() def updata_token(user):
userobj = User.objects.filter(username=user)
if userobj:
userobj = userobj[0]
else:
userobj = User.objects.create(username=user)
tokenobj = VueUserToken.objects.filter(user=userobj)
tokenid = create_token()
if tokenobj:
now = timezone.now()
last_login_time = tokenobj[0].created
interval = now - last_login_time
if interval.seconds > 86400:
tokenobj = tokenobj[0]
tokenobj.key = tokenid
tokenobj.save()
return tokenobj.key
return tokenobj[0].key
else:
tokenobj = VueUserToken.objects.create(user=userobj,key=tokenid)
return tokenobj.key

common\auth\handle_token.py 用户身份验证通过后生成token

  2、创建users这个APP,并测试上面认证与权限的使用

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users',
'rest_framework'
]

settings.py 注册app

from django.conf.urls import url,include
from django.contrib import admin urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^users/', include('users.urls')),
]

urls.py 总url

__author__ = 'tom'
# -*-coding=utf8-*-
from django.conf.urls import url
from users import views urlpatterns = [
url(r'^v1/user/login/$', views.LoginViewSet.as_view(), name='user-login'),
url(r'^v1/userinfo/$', views.UserInfoViewSet.as_view(), name='user-info'),
]

users/urls.py APP中url

# -*- coding: utf-8 -*-
from __future__ import unicode_literals from django.db import models
from django.contrib.auth.models import User # Create your models here.
class VueUserToken(models.Model):
user = models.OneToOneField(User, verbose_name='用户名',unique=True)
key = models.CharField(max_length=255,null=True,blank=True)
created = models.DateTimeField(auto_now=True) class Meta:
verbose_name = 'Vue API Token'
verbose_name_plural = verbose_name def __unicode__(self):
return self.user.username

users/models.py 创建token表

# -*- coding: utf-8 -*-
from __future__ import unicode_literals from django.shortcuts import HttpResponse
from rest_framework.views import APIView
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
import json
from common import ajax
from common.auth.base_views import BaseViews
from common.auth import handle_token class LoginViewSet(APIView):
"""用户登录"""
def __init__(self):
super(LoginViewSet, self).__init__() def get(self,request):
return HttpResponse('ok') def post(self, request, *args, **kwargs):
user = request.data.get('username', '')
pwd = request.data.get('password', '')
username = authenticate(username=user, password=pwd)
if username is None:
return ajax.bad_request(desc='账号密码输入错误!')
else:
key = handle_token.updata_token(user)
return ajax.success(data=str(key)) class UserInfoViewSet(BaseViews):
'''获取用户信息'''
def __init__(self):
super(UserInfoViewSet, self).__init__() def get(self, request, *args, **kwargs):
username = request.query_params.get('username')
data = {'username':username}
return ajax.success(desc='sucess',data=data) def post(self, request):
usernamne = request.data.get('username')
password = request.data.get('password')
if usernamne is None or password is None:
return ajax.bad_request(desc='抱歉,输入的信息不全')
has_user = User.objects.filter(username=usernamne)
if has_user:
return ajax.bad_request(desc='用户名已经存在')
user = User()
user.set_password(password) #让密码更安全,设置密码,给密码加盐
user.username = usernamne
user.is_staff = True
user.is_superuser = True
user.save()
return ajax.success(desc='创建成功')

users/views.py 登录、认证、权限使用举例

  3、测试接口 

      http://127.0.0.1:8000/users/v1/user/login/    # 用户登录接口

      http://127.0.0.1:8000/users/v1/userinfo/     # 创建用户信息(get)、创建用户(post)

      注:获取用户信息请求头必须携带token ( {"Authorization":"1192663f88632adc6595ced0b92d3efd} )

      

1.2 djangorestframework 序列化

  参考博客:http://www.cnblogs.com/wupeiqi/articles/7805382.html

  1、序列化

      注:前端分页时只需出入(page_size,和page参数就能进行分页了)

        http://127.0.0.1:8000/app01/userinfo/page/?page_size=1&page=2
        page_size=1 :指定每页只显示一条数据
        page=2 :显示第二页的数据

from django.conf.urls import url,include
from django.contrib import admin urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^app01/',include('app01.urls')),
]

urls.py

#! /usr/bin/env python
# -*- coding: utf-8 -*-
from django.conf.urls import url
from app01 import views urlpatterns = [
url(r'^userinfo/',views.UserInfoViewSet.as_view()),
]

app01/urls.py

# -*- coding: utf-8 -*-
from __future__ import unicode_literals from django.db import models class UserInfo(models.Model):
name = models.CharField(max_length=64,unique=True)
ut = models.ForeignKey(to='UserType')
gp = models.ManyToManyField(to='UserGroup') class UserType(models.Model):
type_name = models.CharField(max_length=64,unique=True) class UserGroup(models.Model):
group = models.CharField(max_length=64)

app01/models.py

#!/usr/bin/python
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals
from rest_framework import serializers
from app01.models import UserInfo __all__ = [
'UserInfoSerializer',
] # class UserInfoSerializer(serializers.ModelSerializer):
class UserInfoSerializer(serializers.Serializer):
name = serializers.CharField() # 显示普通字段
ut = serializers.CharField(source='ut.type_name') # 显示一对多字段
gp = serializers.SerializerMethodField() # 自定义显示(显示多对多)
xxx = serializers.CharField(source='name') # 也可以自定义显示字段名称 class Meta:
model = UserInfo
fields = ['name']
# fields = '__all__'
validators = [] def get_gp(self,row):
'''row: 传过来的正是 UserInfo表的对象'''
gp_obj_list = row.gp.all() # 获取用户所有组
ret = []
for item in gp_obj_list:
ret.append({'id':item.id,'gp':item.group})
return ret ret = [{
"name": "zhangsan",
"ut": "超级管理员",
"gp": [{
"id": 1,
"gp": "group01"
}, {
"id": 2,
"gp": "group02"
}],
"xxx": "zhangsan"
}, {
"name": "lisi",
"ut": "超级管理员",
"gp": [{
"id": 1,
"gp": "group01"
}],
"xxx": "lisi"
}, {
"name": "wangwu",
"ut": "普通管理员",
"gp": [{
"id": 2,
"gp": "group02"
}],
"xxx": "wangwu"
}]

app01\serializers\userinfo_serializer.py

# -*- coding: utf-8 -*-
from __future__ import unicode_literals from django.shortcuts import render,HttpResponse
from rest_framework.views import APIView
import json
from app01.serializers.userinfo_serializer import UserInfoSerializer
from models import UserInfo class UserInfoViewSet(APIView):
def get(self, request, *args, **kwargs):
obj = UserInfo.objects.all()
ser = UserInfoSerializer(instance=obj,many=True)
ret = json.dumps(ser.data,ensure_ascii=False)
print ret
return HttpResponse(ret)

app01/views.py

  2、djangorestframework渲染器使用

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app01',
'rest_framework',
]

settings.py 中注册 rest_framework

# -*- coding: utf-8 -*-
from __future__ import unicode_literals from django.shortcuts import render,HttpResponse
from rest_framework.views import APIView
from rest_framework.response import Response
import json
from app01.serializers.userinfo_serializer import UserInfoSerializer
from models import UserInfo class UserInfoViewSet(APIView):
def get(self, request, *args, **kwargs):
obj = UserInfo.objects.all()
ser = UserInfoSerializer(instance=obj,many=True) return Response(ser.data)

get请求时以Response返回

    

1.3 djangorestframework 分页

  1、封装分页相关模块

#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals from django.conf import settings
from rest_framework import status
from django.core.paginator import EmptyPage, Paginator, PageNotAnInteger from common import ajax
from common.api_response import JsonResponse def Paginators(objs, request, Serializer):
"""
objs : 实体对象, queryset
request : 请求对象
Serializer : 对应实体对象的类
page_size : 每页显示多少条数据
page : 显示第几页数据
total_count :总共有多少条数据
total :总页数
"""
try:
page_size = int(request.GET.get('page_size', settings.REST_FRAMEWORK['PAGE_SIZE']))
page = int(request.GET.get('page', 1))
except (TypeError, ValueError):
return ajax.bad_request(desc='page and page_size must be integer!') paginator = Paginator(objs, page_size) # paginator对象
total_count = paginator.count
total = paginator.num_pages # 总页数
try:
objs = paginator.page(page)
except PageNotAnInteger:
objs = paginator.page(1)
except EmptyPage:
objs = paginator.page(paginator.num_pages)
print 123455666
print objs
serializer = Serializer(objs, many=True) # 序列化操作
print '####################'
print serializer
print '$$$$$$$$$$$$$$$$$$$'
return JsonResponse(
data={
'detail': serializer.data,
'page': page,
'page_size': page_size,
'total': total,
'total_count': total_count
},
code=status.HTTP_200_OK,
desc='page success') # 返回 def ApiPpaginator(objs_list, request):
"""
objs : 实体对象, queryset
request : 请求对象
Serializer : 对应实体对象的类
"""
try:
page_size = int(request.GET.get('page_size', settings.REST_FRAMEWORK['PAGE_SIZE']))
page = int(request.GET.get('page', 1))
except (TypeError, ValueError):
return ajax.bad_request(desc='page and page_size must be integer!') paginator = Paginator(objs_list, page_size) # paginator对象
total_count = paginator.count
total = paginator.num_pages # 总页数
try:
objs = paginator.page(page)
except PageNotAnInteger:
objs = paginator.page(1)
except EmptyPage:
objs = paginator.page(paginator.num_pages) return JsonResponse(
data={
'detail': objs.object_list,
'page': page,
'page_size': page_size,
'total': total,
'total_count': total_count
},
code=status.HTTP_200_OK,
desc='page success') # 返回

common\api_paginator.py

# -*- coding:utf-8 -*-
from __future__ import absolute_import from rest_framework import status as http_status from common.api_response import JsonResponse __all__ = ['created_success'] def ajax_data(data=None,
code=http_status.HTTP_200_OK,
desc=None,
status=http_status.HTTP_200_OK): return JsonResponse(data=data, code=code, desc=desc, status=status) def success(data=None, desc=None):
return ajax_data(data=data, desc=desc) def error(data=None, desc=None):
return ajax_data(
data=data, code=http_status.HTTP_500_INTERNAL_SERVER_ERROR, desc=desc) def created_success(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_201_CREATED,
desc=desc,
status=http_status.HTTP_201_CREATED) def conflict(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_409_CONFLICT,
desc=desc,
status=http_status.HTTP_409_CONFLICT) def accepted(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_202_ACCEPTED,
desc=desc,
status=http_status.HTTP_202_ACCEPTED) def not_implemented(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_501_NOT_IMPLEMENTED,
desc=desc,
status=http_status.HTTP_501_NOT_IMPLEMENTED) def unauthorized(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_401_UNAUTHORIZED,
desc=desc,
status=http_status.HTTP_401_UNAUTHORIZED) def not_found(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_404_NOT_FOUND,
desc=desc,
status=http_status.HTTP_404_NOT_FOUND) def bad_request(data=None, desc=None):
return ajax_data(
data=data,
code=http_status.HTTP_400_BAD_REQUEST,
desc=desc,
status=http_status.HTTP_400_BAD_REQUEST)

common\ajax.py

# -*- coding: utf-8 -*-
from django.utils import six
from rest_framework.response import Response
from rest_framework.serializers import Serializer class JsonResponse(Response):
"""
An HttpResponse that allows its data to be rendered into
arbitrary media types.
""" def __init__(self,
data=None,
code=None,
desc=None,
status=None,
template_name=None,
headers=None,
exception=False,
content_type='application/json; charset=utf-8'):
"""
Alters the init arguments slightly.
For example, drop 'template_name', and instead use 'data'.
Setting 'renderer' and 'media_type' will typically be deferred,
For example being set automatically by the `APIView`.
""" super(Response, self).__init__(None, status=status) if isinstance(data, Serializer):
msg = ('You passed a Serializer instance as data, but '
'probably meant to pass serialized `.data` or '
'`.error`. representation.')
raise AssertionError(msg) self.data = {"code": code, "desc": desc, "data": data}
self.template_name = template_name
self.exception = exception
self.content_type = content_type if headers:
for name, value in six.iteritems(headers):
self[name] = value

common\api_response.py

  2、分页使用

#! -*- coding:utf8 -*-

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'app01',
] # 分页
REST_FRAMEWORK = {
# 全局分页
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
# 关闭api root页面展示
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
),
'UNICODE_JSON': False,
# 自定义异常处理
'EXCEPTION_HANDLER': (
'common.utils.custom_exception_handler'
), 'PAGE_SIZE': 10}

settings.py

from django.conf.urls import url,include
from django.contrib import admin urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^app01/',include('app01.urls')),
]

urls.py

#! /usr/bin/env python
# -*- coding: utf-8 -*-
from django.conf.urls import url
from app01 import views urlpatterns = [
url(r'^userinfo/$',views.UserInfoViewSet.as_view()),
url(r'^userinfo/page/$',views.UserPageViewSet.as_view()),
]

app01/urls.py

# -*- coding: utf-8 -*-
from __future__ import unicode_literals from django.db import models class UserInfo(models.Model):
name = models.CharField(max_length=64,unique=True)
ut = models.ForeignKey(to='UserType')
gp = models.ManyToManyField(to='UserGroup') class UserType(models.Model):
type_name = models.CharField(max_length=64,unique=True) class UserGroup(models.Model):
group = models.CharField(max_length=64)

app01/models.py

#!/usr/bin/python
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals
from rest_framework import serializers
from app01.models import UserInfo __all__ = [
'UserInfoSerializer',
] # class UserInfoSerializer(serializers.ModelSerializer):
class UserInfoSerializer(serializers.Serializer):
name = serializers.CharField() # 显示普通字段
ut = serializers.CharField(source='ut.type_name') # 显示一对多字段
gp = serializers.SerializerMethodField() # 自定义显示(显示多对多)
xxx = serializers.CharField(source='name') # 也可以自定义显示字段名称 class Meta:
model = UserInfo
fields = ['name']
# fields = '__all__'
validators = [] def get_gp(self,row):
'''row: 传过来的正是 UserInfo表的对象'''
gp_obj_list = row.gp.all() # 获取用户所有组
ret = []
for item in gp_obj_list:
ret.append({'id':item.id,'gp':item.group})
return ret

app01\serializers\userinfo_serializer.py

# -*- coding: utf-8 -*-
from __future__ import unicode_literals from django.shortcuts import render,HttpResponse
from rest_framework.views import APIView
from rest_framework.response import Response
import json
from app01.serializers.userinfo_serializer import UserInfoSerializer
from models import UserInfo
from common.api_paginator import Paginators class UserInfoViewSet(APIView):
def get(self, request, *args, **kwargs):
obj = UserInfo.objects.all()
ser = UserInfoSerializer(instance=obj,many=True)
return Response(ser.data) class UserPageViewSet(APIView):
queryset = UserInfo.objects.all()
serializer_class = UserInfoSerializer def get(self, request, *args, **kwargs):
self.queryset = self.queryset.all()
ret = Paginators(self.queryset, request, self.serializer_class)
print json.dumps(ret.data) # ret.data 返回的是最终查询的json数据
return Paginators(self.queryset, request, self.serializer_class)

app01/views.py

02: djangorestframework使用的更多相关文章

  1. 【Python】djangorestframework 基于django框架的接口开发

    官网:http://www.django-rest-framework.org/#installation 下载:https://pypi.python.org/pypi/djangorestfram ...

  2. 02 Django虚拟环境搭建

    01 创建虚拟环境目录 该目录用于存放所有虚拟环境. cd / mkdir venv cd venv 02 创建当前项目的虚拟环境 virtualenv --python=/usr/bin/pytho ...

  3. 02 drf源码剖析之快速了解drf

    02 drf源码剖析之快速了解drf 目录 02 drf源码剖析之快速了解drf 1. 什么是drf 2. 安装 3. 使用 3. DRF的应用场景 1. 什么是drf drf是一个基于django开 ...

  4. Kotlin中变量不同于Java: var 对val(KAD 02)

    原文标题:Variables in Kotlin, differences with Java. var vs val (KAD 02) 作者:Antonio Leiva 时间:Nov 28, 201 ...

  5. Android游戏开发实践(1)之NDK与JNI开发02

    Android游戏开发实践(1)之NDK与JNI开发02 承接上篇Android游戏开发实践(1)之NDK与JNI开发01分享完JNI的基础和简要开发流程之后,再来分享下在Android环境下的JNI ...

  6. iOS系列 基础篇 02 StoryBoard 故事板文件

    iOS基础 02 StoryBoard 故事板文件 目录: 1. 故事板的导航特点 2. 故事板中的Scene和Segue 3. 本文最后 在上篇HelloWorld工程中有一个Main.storyb ...

  7. [转]Tesseract 3.02中文字库训练

    下载chi_sim.traindata字库下载tesseract-ocr-setup-3.02.02.exe 下载地址:http://code.google.com/p/tesseract-ocr/d ...

  8. Java多线程系列--“JUC锁”02之 互斥锁ReentrantLock

    本章对ReentrantLock包进行基本介绍,这一章主要对ReentrantLock进行概括性的介绍,内容包括:ReentrantLock介绍ReentrantLock函数列表ReentrantLo ...

  9. Oracle Recovery 02 - 常规恢复之不完全恢复

    背景:这里提到的常规恢复指的是数据库有完备可用的RMAN物理备份. 实验环境:RHEL6.4 + Oracle 11.2.0.4 单实例. 二.常规恢复之不完全恢复:部分数据丢失 2.1 重做日志文件 ...

随机推荐

  1. 函数max()优化

    函数max的优化 用途:查询最后支付时间-优化max函数 语句: select max(payment_date)from payment 执行计划:

  2. gispro发布vectortile笔记

    1.https://www.cnblogs.com/escage/p/6387529.html 矢量切片的作用.对于地图中的基础数据图层,或者数据量比较大的矢量图层,只是作渲染用.则需要制作矢量切片, ...

  3. java中二维数组的复制克隆

    https://blog.csdn.net/qq_37232304/article/details/79950022

  4. 2017高教杯数学建模B 题分析

    B题原文 "拍照赚钱"是移动互联网下的一种自助式服务模式.用户下载APP,注册成为APP的会员,然后从APP上领取需要拍照的任务(比如上超市去检查某种商品的上架情况),赚取APP对 ...

  5. <1>Cocos Creator安装和启动

    学习之间需要了解JavaScritp基本语法和面向对象,详情参考https://blog.csdn.net/jadeshu/article/category/7476938 1.下载Cocos Cre ...

  6. 17.Setters/getters

    知道类的成员变量何时因某种原因发生变化通常很有用.也可能需要以某种方式封装其访问. 为此,GDScript使用 setget 关键字提供了一个 setter/getter 语法.在变量定义后可直接使用 ...

  7. mybatis-config.xml

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC ...

  8. 【Linux学习一】命令查看与帮助

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 一.Linux执行命令流程:shell->bash(解释器 执行 ...

  9. 入坑tensorflow

    win10 CPU版,anaconda prompt命令行一句话,pip install --upgrade tensorflow搞定.比caffe好装一万倍. gpu版没装成,首先这个笔记本没装cu ...

  10. HashMap集合存储自定义类

    第一种情况,key为String,value为自定义类person类: 输出结果,key重复的被去掉了,key重复的那个value值之前的被最后一个覆盖了: 第二种情况,key为自定义类person类 ...