2 JoseThree

尚未进行身份认证

我要认证

暂无相关简介

等级
TA的排名 11w+

urllib库

* ua = random.choice(ua_list) #随机选择一个user-agent信息* request = Request(url) #传奇请求对象* request.add_header('User-Agent', ua) #添加请求头信息* response.read() # 读取返回的内容

2019-07-28 23:35:53

lxml,etree简单爬取数据

# //div[@class='billboard-bd']//a/text()import requestsfrom lxml import etreeurl = 'https://movie.douban.com/'headers = {'User-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTM...

2019-07-27 23:06:37

request库

from requests.models import Responseimport requestsurl = 'https://movie.douban.com/'res:Response = requests.request("GET", url, headers={'User-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWe...

2019-07-27 20:20:05

celery

from celery import Celeryapp = Celery()print(app)@app.task(name='myfirsttask')def add(x, y): print('enter ~~~') ret = x + y import time time.sleep(10) return retprint(app...

2019-07-26 17:16:43

Django模板技术

Django模板技术urls配置templates/indexDTL语法urls配置from django.template import loaderfrom django.http import JsonResponse, HttpRequest, HttpResponsefrom django.shortcuts import renderdef index(request)...

2019-07-22 19:11:18

js的MiXin技术

const A = cls => class extends cls { //函数A返回一个继承自cls的子类 constructor (...arges){ console.log('A') super(...arges); if (typeof (this.stri) !=='function'){ //判断子类是否有stri方...

2019-07-09 22:06:17

Promise

var promise = new Promise( function (resolve,reject) { console.log('do some thing') resolve('dit it') console.log('~~~~~~~~~~~') reject('failed') });var p1= ...

2019-07-06 17:54:15

对象操作

var obj = { a:100, b:200, c:300,}console.log(obj.a,obj.b,obj.c)var new1 = Object.keys(obj)var values = Object.values(obj)var entries = Object.entries(obj)console.log(new1)console....

2019-07-06 16:40:38

文件拷贝

fn1 = 'E:/test/a1.txt'fn2 = 'E:/test/a2.txt'with open(fn1,'w') as f: f.writelines('\n'.join(['abc','123','xyz']))with open(fn1,'rb') as f1: with open(fn2,'wb') as f2: length = 16*...

2019-07-05 16:38:22

文件操作os,pathlib

import osfrom pathlib import Pathp = Path('E:/test/')print(list(p.glob('**/*'))) #返回当前目录下的所有内容递归print(os.listdir(p)) #返回当前目录下的所有内容不递归print(os.listdir('E:/test/')) #同上...

2019-07-04 20:29:08

JS对象模型

要创建 Point 的新实例,必须使用 new 操作符。以这种方式调用构造函数实际上会经历以下 4个步骤:(1) 创建一个新对象;(2) 将构造函数的作用域赋给新对象(因此 this 就指向了这个新对象) ;(3) 执行构造函数中的代码(为这个新对象添加属性) ;(4) 返回新对象。老语法function Point (x,y) { // console.log('Poin...

2019-07-01 22:04:14

JS函数

递归函数JS里面:const sum = function fn(n){ return n===0 ? 0: n + fn(--n)}console.log(sum(2))Python里面:def foo1(n): # if n == 0: # return 0 # else: # return n + foo1(n-1)...

2019-07-01 19:20:28

JS语法

语句块function hello() { let a = 1; var b = 2; c = 3}if (true) { let d = 4; var e = 5; f = 6 if (1) { console.log(d) console.log(e) console.log(f)...

2019-06-30 23:48:12

js++--简单运算

let d = --i - i-- - i-- - i // d=-1 i=-1 d=0 i=-2 d= 2 i = -3 d=2+3 i=-3console.log(d, i)let e = ++i + i++ + i++ + i// e= 1 i=1 e=2 i=2 ...

2019-06-29 21:22:11

ORM具体操作

import sqlalchemy, enumfrom sqlalchemy import create_engine, Column, Integer, String, Date, ForeignKey, Enum, and_from sqlalchemy.orm import sessionmaker, relationshipfrom sqlalchemy.ext.declarativ...

2019-06-29 16:35:03

元编程

简单理解:class Meta(type): #type是元类,创建类的类 Meta继承自type,就具备了创造类的功能 def __new__(cls, *args, **kwargs): print(cls) print(args) print(kwargs) name, _, attr = args ...

2019-06-29 13:19:34

动态规划

求最大子串a = 'xxxxabcd'b = 'abcd'def foo1(a, b): length_a = len(a) length_b = len(b) matrix = [[0]*length_a for _ in range(length_b)] xmax = 0 xindex = 0 for i, x in enumerate(b...

2019-06-27 19:08:35

re模块

import re# 取出字符串string8中所有的天气状态string8 = "{ymd:'2018-01-01',tianqi:'晴',aqiInfo:'轻度污染'}," \ "{ymd:'2018-01-02',tianqi:'阴~小雨',aqiInfo:'优'}," \ "{ymd:'2018-01-03',tianqi:'小雨~中雨',aqi...

2019-06-27 09:16:26

pymsql事物管理

1,conn 建立连接2,cursor 建立游标3,ping测试4,建立查询语句5,cursor.execute 执行import pymysqlfrom pymysql.cursors import DictCursorconn = pymysql.connect('192.168.106.128', 'xinzhu', '123456', 'test')cursor = co...

2019-06-26 21:22:41

定义外键约束

定义外键约束:from sqlalchemy import ForeignKey例如:emp_no = Column(Integer, ForeignKey('employees.emp_no', ondelete='CASCADE'), primary_key=True)

2019-06-26 18:05:24

查看更多

勋章 我的勋章
  • GitHub
    GitHub
    绑定GitHub第三方账户获取
  • 持之以恒
    持之以恒
    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
  • 勤写标兵Lv3
    勤写标兵Lv3
    授予每个自然周发布7篇到8篇原创IT博文的用户。本勋章将于次周周三上午根据用户上周的博文发布情况由系统自动颁发。