python项目需求文件requirements.txt的创建及安装
版权声明:https://blog.csdn.net/study_in https://blog.csdn.net/study_in/article/details/86091599 python项目中必须包含一个 requirements.txt 文件,用于记录所有依赖包及其精确的版本号。以便新环境部署。 在虚拟环境中使用pip生成: (venv) $ pip freeze >requirements.txt
安装或升级包后,最好更新这个文件。 当需要创建这个虚拟环境的完全副本,可以创建一
python根据经纬度判断两点之间的距离
版权声明:https://blog.csdn.net/study_in https://blog.csdn.net/study_in/article/details/86136504 调用python的math包 from math import radians, cos, sin, asin, sqrt
#公式计算两点间距离(m)
def geodistance(lng1,lat1,lng2,lat2):
#lng1,lat1,lng2,lat2 = (120.12802999999
python3中的setattr(),getattr(),hasattr(),delattr()
版权声明:https://blog.csdn.net/study_in https://blog.csdn.net/study_in/article/details/86159591 示例: >>> class Car:
... def __init__(self):
... pass
...
>>> car1 = Car()
>>> car1.color = 'red'
>>> hasattr(car1,'color')
True
>>> hasattr(c
Django中信号的实现
版权声明:https://blog.csdn.net/study_in https://blog.csdn.net/study_in/article/details/86162410 signal在django中用于发送通知,在django中内置的信号包括 post_save, pre_delete 等;使用这些信号可以很方便实现业务逻辑与model之间的解耦。 内建signal的使用 django 内部有些定义好的signal供我们使用: 模型相关: pre_save 对象save前触发
VBA批量生成word(如offer)
Excel里面有客户的名字、身份证、性别、手机号,通过批量更新offer的这4个变量批量生成offer。 VBA代码如下: Sub CreateWord() Dim mypath, Newname, i, XB, wApp mypath = ThisWorkbook.Path & “\” For i = 2 To [a1048576].End(xlUp).Row Newname = “offer-” & Range(“a” & i) & “.docx” ‘给新生成的表起个名称 FileCopy
python 发送邮件基础
python 发送邮件基础代码 import datetime import email import shutil import os from email.mime.application import MIMEApplication import smtplib as sm import email.mime.multipart import email.mime.text current_date = datetime.date.today()- datetime.timedelta(
tensorflow以逻辑回归模拟二维数据
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt plotdata = { “batchsize”:[], “loss”:[] } def moving_average(a, w=10): if len(a) < w: return a[:] return [val if idx < w else sum(a[(idx-w):idx])/w for idx, val in enumerate(a
决策树--集体智慧编程
预测一个网站上有多少用户愿意为了某些高级功能支付费用 数据python: my_data=[[‘slashdot’,‘USA’,‘yes’,18,‘None’], [‘google’,‘France’,‘yes’,23,‘Premium’], [‘digg’,‘USA’,‘yes’,24,‘Basic’], [‘kiwitobes’,‘France’,‘yes’,23,‘Basic’], [‘google’,‘UK’,‘no’,21,‘Premium’], [’(direct)’,‘New Z
使用CBrother做TCP服务器与C++客户端通信
使用CBrother脚本做TCP服务器与C++客户端通信 工作中总是会遇到一些对于服务器压力不是特别大,但是代码量比较多,用C++写起来很不方便。对于这种需求,我选择用CBrother脚本做服务器,之所以不选择Python是因为python的语法我实在是适应不了,再来CBrother的网络框架也是用C++封装的异步IO,性能还是很有保证的。 废话不多说,先来看下服务器代码,我这里只是记录一个例子,不是全部代码,方便后面做项目的时候直接来自己博客复制代码修改。 1 import
js全选反选按钮实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> </title> </head> <body> <form action=""> <p><input type="checkbox" >我是谁</p> <p><input type="checkbox" >我在哪</p> <p><input type="checkbox" >我在做什么呢</p> <p><input type="checkbox" >你知
【TJOI2015】线性代数
题面 题解 要求的是 \[ \sum_{i=1}^n\sum_{j=1}^na_ia_jb_{i,j} - \sum_{i=1}^na_ic_i \] 可以看出这是一个最大权闭合子图问题 代码 #include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define RG register
#define file(x) freopen(#x".in", "r", stdin);freopen(#x".out
Django的锁和事务
Django的锁和事务 锁 select_for_update(nowait=False, skip_locked=False) 返回一个锁住行直到事务结束的查询集,如果数据库支持,它将生成一个 SELECT ... FOR UPDATE 语句。 举个例子: entries = Entry.objects.select_for_update().filter(author=request.user) 所有匹配的行将被锁定,直到事务结束。这意味着可以通过锁防止数据被其它事务修改。 一般情况下如果
laravel 用户认证简单示例
一、模型代码: 实现接口:\Illuminate\Contracts\Auth\Authenticatable 并引入trait:\Illuminate\Auth\Authenticatable <?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Manager extends Model implements \Illuminate\Contracts\Auth\Authenticatable
使用Requests和BeautifulSoup爬取妹子图
项目说明: Python新手,第一个爬虫项目,网络爬虫算是一项能提升编程学习兴趣的活动了,让Python学习不再枯燥。 Python版本3.7.2 需要模块:requests,os,beautifulsoup 爬虫目标地址https://www.mzitu.com/xinggan/ 项目实现: 首先导入模块,配置请求头,如果没有图片地址会是空链接 # -*- coding:utf-8 -*- import requests,os
from bs4 import BeautifulSoup
Pa
numpy.unpackbits()
numpy.unpackbits numpy.unpackbits(myarray, axis=None) Unpacks elements of a uint8 array into a binary-valued output array. Each element of myarray represents a bit-field that should be unpacked into a binary-valued output array. The shape of the out
【循环数组的最大字串和】Maximal-sum Subsequence
【循环数组的最大字串和】Maximal-sum Subsequence PROBLEM 题目描述 给一个 N×N 的矩阵 M,可以取连续的一段数(必须是横着或者竖着或者斜着,这个矩阵是循环的,具体如下)。要求找到一个子序列,使得这个序列的和最大。 对于 N=8 的矩阵,如下序列都是合法的: M2,1,M2,2,M2,3,M2,4,M2,5,M2,6,M2,7,M2,8. M2,2,M2,3,M2,4. M2,6,M2,7,M2,8,M2,1,M2,2. M4,3,M5,3,M6,3,M7,3.
煎蛋网爬虫之JS逆向解析img路径
图片使用js onload事件加载 <p><img src="//img.jandan.net/img/blank.gif" onload="jandan_load_img(this)" /><span class="img-hash">Ly93eDEuc2luYWltZy5jbi9tdzYwMC8wMDd1ejNLN2x5MWZ6NmVub3ExdHhqMzB1MDB1MGFkMC5qcGc=</span></p> 找到soureces 文件中对应的js 方法jandan_load_img
python 离群点检测
1 import numpy as np
2 import pandas as pd
3 from sklearn.cluster import KMeans
4 import matplotlib.pyplot as mp
5
6
7 def get_data_zs(inputfile):
8 data = pd.read_excel(inputfile, index_col='Id', encoding='gb18030')
9 data_zs = 1.
今日推荐
周排行