Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Browsing all 9596 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

局部加权回归(Locally weighted linear regression)

通常情况下的线性拟合不能很好地预测所有的值,因为它容易导致欠拟合(under fitting),比如数据集是 一个钟形的曲线。而多项式拟合能拟合所有数据,但是在预测新样本的时候又会变得很糟糕,因为它导致数据的 过拟合(overfitting),不符合数据真实的模型。 今天来讲一种非参数学习方法,叫做局部加权回归(LWR)。为什么局部加权回归叫做非参数学习方法呢? 首...

View Article


Image may be NSFW.
Clik here to view.

Why Are There So Many Pythons? A Python Implementation Comparison

Guest post from Toptal Engineering Blog . python is amazing. Surprisingly, that’s a fairly ambiguous statement. What do I mean by ‘Python’? Do I mean Python the abstract interface? Do I mean CPython,...

View Article


结算开发中遇到的坑

坑1:浮点数不精确性 In [1]: 0.1+0.1+0.1-0.3 Out[1]: 5.551115123125783e-17 解决办法: In [2]: from decimal import Decimal In [3]: Decimal('0.1') + Decimal('0.1') + Decimal('0.1') - Decimal('0.3') Out[3]:...

View Article

Image may be NSFW.
Clik here to view.

Peter Bengtsson: crontabber now supports locking, both high- and low-level

tl;dr; In other words, you can now have multiple servers with crontabber, all talking to a central PostgreSQL for its state, and not have to worry about jobs being started more than exactly once. This...

View Article

Process Python Collections with Functional Programming

I develop Spark applications with Scala, and it has a very powerful collection system , in which functional programming is certainly a key. Java 8 also introduces Lambda Expression and Stream API. In...

View Article


Python BaseHTTPServer 介绍

python BaseHTTPServer 介绍 一点号数据玩家5小时前 限时干货下载:添加微信公众号“数据玩家「fbigdata」” 回复【7】免费获取【完整数据分析资料!(包括SPSS、SAS、SQL、EXCEL、Project)!】 本文针对 python 2.7 版本,介绍了 BaseHTTPServer 这个库的使用方法。 这个库是 python 自带的标准库的一部分,不需要额外安装,在...

View Article

How-to Deploy Django Apps with uWSGI and Nginx on Ubuntu

Django 的部署可以有很多方式,采用 nginx + uwsgi 的方式是其中比较常见的一种方式。 准备工作 安装所需软件 pipinstallDjango apt-getinstallnginx pipinstalluwsgi # 注: 在 Debian/Ubuntu 系统中需要安装 python-dev 基本测试 创建一个 test.py 的文件 # test.py...

View Article

Gunicorn 19.7.0 发布,Python 的 HTTP 服务器

Gunicorn 19.7.0 发布了,Gunicorn 绿色独角兽'是一个python WSGI UNIX的HTTP服务器。这是一个pre-fork worker的模型,从Ruby的独角兽(Unicorn )项目移植。该Gunicorn服务器大致与各种Web框架兼容,只需非常简单的执行,轻量级的资源消耗,以及相当迅速。 该版本至少要求 Python 2.6.0 , 包含如下改进内容:...

View Article


Python Fire ―― Python 命令行接口自动生成库

python Fire 是 Google 开源的一个可从任何 Python 代码自动生成命令行接口(CLI)的库。 Python Fire 是一种在 Python 中创建 CLI 的简单方法。 Python Fire 是开发和调试 Python 代码的有用工具。 Python Fire 帮助探索现有代码或将其他人的代码转换为CLI。 Python Fire 使 Bash 和 Python...

View Article


Image may be NSFW.
Clik here to view.

伯努利分布(Bernoulli distribution)

伯努利分布 是一种离散分布,有两种可能的结果。1表示成功,出现的概率为p(其中0<p<1)。0表示失败,出现的概率为q=1-p。这种分布在人工智能里很有用,比如你问机器今天某飞机是否起飞了,它的回复就是Yes或No,非常明确,这个分布在分类算法里使用比较多,因此在这里先学习 一下。 概率分布有两种类型:离散(discrete)概率分布和连续(continuous)概率分布。...

View Article

使用CLion编辑C工程

最近正在研究linux C代码编辑器,确实也不太喜欢SI(windows看代码还行,编辑一般,同步麻烦), 尝试使用CLion,但对makefile工程支持不好,怎么编译还没搞懂, 阅读、编辑还不错,智能提示、语法检查、函数跳转、查引用都挺好用的。 不过要想使用CLion的这些功能需要添加工程中的h文件到CMakeList.txt,...

View Article

Image may be NSFW.
Clik here to view.

flask+ngrok微信公众号搭建小试

利用ngrok+flask搭建微信公众平台,基本分为三步:1. ngrok配置;2. 微信公众平台配置;3. flask搭建。基本的数据流走向如下图所示: 1. ngrok配置 ngrok主要是为使用nat上网、没有公网地址资源的用户提供一个内网和外网映射的工具,通过它可以在公网访问内网的资源。...

View Article

Image may be NSFW.
Clik here to view.

BoPress 1.1 发布,Python 通用后台

BoPress 1.1 发布,主要改进内容包括: SQLAlchemySession完全在插件中创建,方便连接池及相关DB参数等配置 增强插件结构,每个插件都是一个独立的App,有自己的静态文件及模板文件 增加控制数据表行访问的对象权限,并增加权限对象联动删除监听及 权限对象联动 批量删除辅助删除函数 运行环境适配到2.7+ 各种重构及优化 权限对象使用示例: from bopress.user...

View Article


Amazing hacks of Python

python is indeed one of the smart and most trending language. Here are some cool hacks that makes a python superb among all other languages. List comprehensions: List comprehension is best and...

View Article

Python 3.6.1rc1 is now available for testing

python 3.6.1rc1 is now available. Python 3.6.1rc1 is the release candidate for the first maintenance release of Python 3.6, which was initially released in 2016-12 to great interest. Three months...

View Article


Python -- Records项目学习

Records学习笔记 Records链接地址 1.__getitem__(self, key) 内建方法(Build-in) 例子: 1 class Test(object): 2 3 def __getitem__(self, key): 4 5 print("test") 6 7 return 1 8 9 10 11 t = Test() 12 13 print(t["m"]) 运行结果:...

View Article

PyBites: Code Challenge 08 - House Inventory Tracker - review

It's end of the week again so we review the code challenge of this week . It's never late to join, just fork our challenges repo and start coding. Learning Julian The simplicity of this challenge is...

View Article


Image may be NSFW.
Clik here to view.

django ‘int’ object has no attribute ‘keys’

django ‘int’ object has no attribute ‘keys’ Posted on March 5, 2017 by Serdar Osman Onur Being new to Django, sometimes I face interesting problems. If it is very late and you are very tired, It...

View Article

python中struct.pack()函数和struct.unpack()函数

python中的struct主要是用来处理C结构数据的,读入时先转换为Python的字符串类型,然后再转换为Python的结构化类型,比如元组(tuple)啥的~。一般输入的渠道来源于文件或者网络的二进制流。 1.struct.pack()和struct.unpack() 在转化过程中,主要用到了一个格式化字符串(format strings),用来规定转化的方法和格式。 下面来谈谈主要的方法:...

View Article

关于反爬虫的一个思考

最近在开发一个python的系统,在写爬虫的时候突然想到一个特别猥琐的对付使用脚本进行批量检测的一个小方法。 我们在进行批量扫描并检测的时候,都可能会调用一些系统命令,比如如下代码: ... for i in get_new_urls: os.system("python sqlmap.py -u %s" % i) ... 以上代码,如果我们网站的url里有下面的一个链接: <a...

View Article
Browsing all 9596 articles
Browse latest View live