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

Image may be NSFW.
Clik here to view.

python web服务学习――uWSGI

最近由于工作的需要,需要使用python来部署一些web服务,由于之前对python了解较少,故而学习过程花了较多的时间,在此,将自己的学习过程记录下来,方便日后查询。 在前辈的推荐下,首先学习的是uWSGI。 开始,只要也解到uWSGI是一个Web服务器,它实现了WSGI协议、uwsgi、http等协议就可以啦,关于那些名字相似的协议的具体内容,以后再慢慢深入学习吧。...

View Article


Python学习【第一篇】Python简介

python介绍 发展史 Python 2 or 3? 一、 Python介绍 python的创始人为吉多范罗苏姆(Guido van Rossum)。1989年的圣诞节期间,吉多范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继承。 最新的TIOBE排行榜,Python赶超php占据第五,Python崇尚优美、清晰、简单,是一个优秀并广泛使用的语言。...

View Article


Learning Python Variables

We all know that variables are a key part of programming and scripting languages, and sure enough, they are a big part of python. Here is how simple they are to implement: #Today we are going to create...

View Article

Image may be NSFW.
Clik here to view.

How to save Scikit Learn models with Python Pickle library

Save the Scikit Learn models Save the trained scikit learn models with python Pickle The final and the most excitingphase in thejourney of solving the data science problems is how well the trained...

View Article

Image may be NSFW.
Clik here to view.

Python已从Mercurial迁移到GitHub

python已从Mercurial迁移到GitHub 一点号开源派4小时前 Python 已经正式迁移版本控制系统 Mercurial到源码托管平台 GitHub。Python 社区前几年曾讨论是否迁移到 GitHub 或者GitLab, 以改进Python 开发流程。考虑到开发者们更熟悉GitHub, Python语言之父Guido van...

View Article


Worst/Trickiest code I have ever seen

It’s easy to write bad code, but it takes a real genius to produce truly terrible code. And the guys who wrote the python program hyperopt were clearly very clever. Have a look at this function:...

View Article

Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转 ...

1、去空格及特殊符号 s.strip() s.lstrip() s.rstrip() s.strip().lstrip().rstrip(',') 声明:s为字符串,rm为要删除的字符序列 s.strip(rm) 删除s字符串中开头、结尾处,位于rm删除序列的字符 s.lstrip(rm) 删除s字符串中开头处,位于rm删除序列的字符 s.rstrip(rm)...

View Article

Image may be NSFW.
Clik here to view.

NumPy in Python | Set 2 (Advanced)

NumPy in python | Set 1 (Introduction) This article discusses some more and a bit advanced methods available in NumPy. Stacking: Several arrays can be stacked together along different axes. np.vstack:...

View Article


Cleaning up Django Persistent Database Connections

For the past year at work we have been utilizing more Kafka infrastructure for what typically would have been handled using celery workers. This has led to some interesting rediscoveries of Django ORM....

View Article


Image may be NSFW.
Clik here to view.

Python数据分析笔记――Numpy、Pandas库

Numpy库 Numpy最重要的一个特点是就是其N维数组对象,即ndarray,ndarray是一个通用的同构数据多维容器,其中的所有元素必须是相同类型的。每个数组都有一个shape(一个表示各维度大小的元组,即表示有几行几列)和dtype(一个用于说明数组数据类型的对象)。本节将围绕ndarray数组展开。 Numpy基础 1、创建ndarray数组...

View Article

Image may be NSFW.
Clik here to view.

Scrapy学习(四) 爬取微博数据

Scrapy学习(三) 爬取豆瓣图书信息 接上篇之后。这次来爬取需要登录才能访问的微博。 爬虫目标是获取用户的微博数、关注数、粉丝数。为建立用户关系图(尚未实现)做数据储备 准备 安装第三方库 requests 和 pymongo 安装MongoDB 创建一个weibo爬虫项目 如何创建Scrapy项目之前文章都已经提到了,直接进入主题。 创建Items...

View Article

Two flavors of differential privacy

How many secrets do you have? This is a quick post, ruminating on the difference between two flavors of differential privacy in common use. I'm a fan of one, and the other weirds me out a bit. I think...

View Article

Image may be NSFW.
Clik here to view.

Python入门(三):解析

本篇我们主要讲一下第一篇教程提到的解析。这次我们换一个更复杂的例子,主要教一下大家如何使用审查元素找到我们需要的数据。这只是一个初步的对于HTML解析的方法,更多奇怪的问题,我们会在之后的教程通过实例一个一个深入探讨。 今天我们的示例网页是:巨潮资讯网,我们的目标是获取所有的股票代码和对应的公司名称。 一、HTML简介...

View Article


Custom error handler in Django Rest Framework

Django personally is still my favorite framework for backend. It provides great documentation, active community, and it's provides great API for us developers to get started really quick. This goes to...

View Article

详解python脚本自动生成需要文件实例代码

python脚本自动生成需要文件在工作中我们经常需要通过一个文件写出另外一个文件,然而既然是对应关系肯定可以总结规律让计算机帮我们完成,今天我们就通过一个通用文件生成的python脚本来实现这个功能,将大家从每日重复的劳动中解放!定义一个函数def produceBnf(infilename,outfilename): List=[] with open(infilename,'r') as...

View Article


Python中文件I/O高效操作处理的技巧分享

如何读写文本文件?实际案例某文本文件编码格式已直(如UTF-8,GBK,BIG5),在python2.x和python3.x中分别如何读取这些文件?解决方案字符串的语义发生了变化: python2 python3 str bytes unicode str python2.x 写入文件前对 unicode 编码,读入文件后对二进制字符串解码>>> f =...

View Article

Image may be NSFW.
Clik here to view.

Django应用程序中如何发送电子邮件详解

前言在Django应用程序中发送电子邮件最常见的用例是密码重置、帐户激活和发送与您的应用程序相关的一般通知。下面来看看详细的介绍吧。配置Django发送电子邮件要配置您的Django应用程序,添加下面的参数到你settings.py:# 主机EMAIL_HOST = "smtp.sina.com"# 端口EMAIL_PORT = 25# 发件人邮箱EMAIL_HOST_USER =...

View Article


Image may be NSFW.
Clik here to view.

Python算法应用实战之栈详解

栈(stack)栈又称之为堆栈是一个特殊的有序表,其插入和删除操作都在栈顶进行操作,并且按照先进后出,后进先出的规则进行运作。如下图所示例如枪的弹匣,第一颗放进弹匣的子弹反而在发射出去的时候是最后一个,而最后放入弹匣的一颗子弹在打出去的时候是第一颗发射出去的。栈的接口如果你创建了一个栈,那么那么应该具有以下接口来进行对栈的操作 接口 描述 push() 入栈 pop() 出栈 isEmpty()...

View Article

Image may be NSFW.
Clik here to view.

Python算法应用实战之队列详解

队列(queue)队列是先进先出(FIFO, First-In-First-Out)的线性表,在具体应用中通常用链表或者数组来实现,队列只允许在后端(称为rear)进行插入操作,在前端(称为front)进行删除操作,队列的操作方式和堆栈类似,唯一的区别在于队列只允许新数据在后端进行添加(摘录维基百科)。如图所示队列的接口一个队列至少需要如下接口: 接口 描述 add(x) 入队 delete()...

View Article

Image may be NSFW.
Clik here to view.

Python 常见os.path工具

python 常见os.path工具 一点号Python热爱者昨天 内嵌的os.path模块提供了一整套目录处理相关工具,比如它提供的可移植函数可以用来检查文件类型(isdir,isfile等)、测试文件是否存在(exists),以及通过文件名来获取文件的大小(getsize): >>> import os >>>...

View Article
Browsing all 9596 articles
Browse latest View live