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

Python 常用 PEP8 编码规范详解

python 常用 PEP8 编码规范代码布局缩进 每级缩进用4个空格。 括号中使用垂直隐式缩进或使用悬挂缩进。EXAMPLE:# (垂直隐式缩进)对准左括号foo = long_function_name(var_one, var_two, var_three, var_four)# (悬挂缩进) 一般情况只需多一层缩进foo = long_function_name( var_one,...

View Article


Image may be NSFW.
Clik here to view.

python学习之面向对象【入门初级篇】

前言最近在学习python的面向对象编程,以前是没有接触过其它的面向对象编程的语言,因此学习这一部分是相当带劲的,这里也总结一下。概述 python支持多种编程范式:面向过程、面向对象、面向切面(装饰器部分)等。 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类和封装,让开发“更快更好更强...” OOP思想...

View Article


Image may be NSFW.
Clik here to view.

Python中struct模块对字节流/二进制流的操作教程

前言最近使用python解析IDX文件格式的MNIST数据集,需要对二进制文件进行读取操作,其中我使用的是struct模块。查了网上挺多教程都写的挺好的,不过对新手不是很友好,所以我重新整理了一些笔记以供快速上手。注:教程中以下四个名词同义:二进制流、二进制数组、字节流、字节数组快速上手在struct模块中,将一个整型数字、浮点型数字或字符流(字符数组)转换为字节流(字节数组)时,需要使用格式化字符...

View Article

python使用xlrd与xlwt对excel的读写和格式设定

前言python操作excel主要用到xlrd和xlwt这两个库,即xlrd是读excel,xlwt是写excel的库。本文主要介绍了python使用xlrd与xlwt对excel的读写和格式设定,下面话不多说,来看看详细的实现过程。脚本里先注明# -*- coding:utf-8 -*-   1.  确认源excel存在并用xlrd读取第一个表单中每行的第一列的数值。import xlrd,...

View Article

Python第三方库xlrd/xlwt的安装与读写Excel表格

前言相信大家都应该有所体会,在平时经常会遇到处理 Excel 表格数据的情况,人工处理起来实在是太麻烦了,我们可以使用 python 来解决这个问题,我们需要两个 Python 扩展, xlrd 和 xlwt...

View Article


Image may be NSFW.
Clik here to view.

python实现的多线程端口扫描功能示例

本文实例讲述了python实现的多线程端口扫描功能。分享给大家供大家参考,具体如下:下面的程序给出了对给定的ip主机进行多线程扫描的Python代码#!/usr/bin/env python#encoding: utf-8import socket, sys, thread, timeopenPortNum = 0socket.setdefaulttimeout(3)def usage():...

View Article

Python 字符串大小写转换的简单实例

①所有字母都转换为大写# -*- coding:utf-8 -*-if __name__ == "__main__":    a = 'hello, world!'    print(a.upper())输出:HELLO, WORLD!②所有字母都转换为小写# -*- coding:utf-8 -*-if __name__ == "__main__":    a = 'HELLO, WORLD!'...

View Article

Image may be NSFW.
Clik here to view.

Kaggle | 使用Python和R绘制数据地图的十七个经典案例(附资源)

Kaggle | 使用python和R绘制数据地图的十七个经典案例(附资源) 一点号大数据文摘3小时前 php?url=0FW4ptXBbF" alt="Kaggle | 使用Python和R绘制数据地图的十七个经典案例(附资源)" />大数据文摘作品,转载具体要求见文末 编译团队 | 寒小阳 黄念 黄卓君 作者|Megan Risdal...

View Article


My experience with type hints and mypy

The CLA bot for the PSF is designed defensively because if the bot accidentally lets a pull request through from someone that has not signed the CLA that could lead to legal troubles. To alleviate any...

View Article


Image may be NSFW.
Clik here to view.

知乎Live全文搜索之使用Elasticsearch全文搜索

一般的网站都会包含搜索功能,它能帮助用户发现没有找到想要的东西,甚至能帮助用户挖掘到兴趣,这对提升用户对网站的黏性和用户体验有非常大的帮助。举个豆瓣的例子,用户可以在主站的搜索里面找到电影、书籍、音乐、用户、小站、小组、游戏等相关内容。...

View Article

Mark Needham: Go vs Python: Parsing a JSON response from a HTTP API

As part of a recommendations with Neo4j talk that I’ve presented a few times over the last year I have a set of scripts that download some data from the meetup.com API . They’re all written in python...

View Article

Python 奇技淫巧 (三) 函数

0X00 任意个参数 python中一般定义函数是这样的 def add(a, b) ,参数的个数是固定的,那么怎么才可以接收任意多个参数就像 rm 1.txt 2.jpg 3.mp3 4.cpp 这样?很简单,使用 * 和 ** 就可以。下面代码里第一个参数a接收到了 hello,world 而 *b 则接收到了其余所有的参数,将其作为一个元组。 #!/usr/bin/python #...

View Article

Image may be NSFW.
Clik here to view.

Python的多线程与多进程简介-上

作者:杨冬 欢迎转载,也请保留这段声明。谢谢! 出处: https://andyyoung01.github.io/ 或 http://andyyoung01.16mb.com/ python允许我们使用它的APIs编写多线程或多进程应用。本篇就来了解一下Python多线程与多进程的基本概念,下篇了解一下实际的代码实例。 Python的多线程或多进程概述...

View Article


New Release Of Nim Borrows From Python, Rust, Go, and Lisp

An anonymous reader writes: "Nim compiles and runs fast, delivers tiny executables on several platforms, and borrows great ideas from numerous other languages ," according to InfoWorld. After six...

View Article

Image may be NSFW.
Clik here to view.

终于学会承认自己做不到

要说 2016...

View Article


Image may be NSFW.
Clik here to view.

Understanding Higher Order Local Gradient Computation for Backpropagation in...

Introduction One of the major difficulties in understanding how neural networks work is due to the backpropagation algorithm. There are endless texts and online guides on backpropagation, but most are...

View Article

Image may be NSFW.
Clik here to view.

A Few Django ORM Mistakes

See if you can figure out what's wrong with the code snippets below! Ask yourself what the problem is, what effect will it have, and how can you fix it? These examples are for Django, but probably...

View Article


Fensterbrief - a python script to organize and work with letters based on...

I use LaTeX for more than a decade. Naturally it is my preferred tool suite when it comes to writing letters. Since working with LaTeX and doing office work requires a bit book keeping, I started...

View Article

Image may be NSFW.
Clik here to view.

What is a variable?

You can visualize a variable 1 as a box that contains a thing 2 . For example, this variable called x contains an integer 0: This other variable called most_recent_email contains a pointer (more...

View Article

Python 终端下中文字符对齐处理和编码续

本来是修改自己一个终端小程序的宽字符处理,然后就和编码纠结上了。 以前总结过一篇python Encoding。 这两天花了不少时间继续研究了下这块,越研究越让人迷糊,还存在不少疑问。只能说在研究和总结这块时,我的内心是崩溃的……希望以后不再在这块纠结。 以下总结在环境 linux,Python2.7 下研究。 先谈谈终端下中文字符(宽字符)的对齐输出问题: 终端下中文字符(宽字符)的对齐输出问题...

View Article
Browsing all 9596 articles
Browse latest View live