Python 信号处理 signal 模块
signal模块简介 最近在看linux signal 相关内容,signal可以被用来进程间通信和异步处理。python标准库提供了signal包可以用来处理信号相关。这里讨论的是Unix系统中Python的signal模块。 signal简单示例 官方文档上有这样的示例: import signal, os # 定义一个信号处理函数,该函数打印收到的信号,然后raise IOError def...
View ArticlePython学习记录day4
1.内置函数补充 callable(object) 检查对象object是否可调用 1、类是可以被调用的 2、实例是不可以被调用的,除非类中声明了__call__方法 def f1(): print("test") f2 = "test" print(callable(f1)) print(callable(f2)) True False chr(i)返回整数i对应的ASCII字符...
View Articlen’th Pentagonal Number
Given an integer n, find the nth Pentagonal number. First three pentagonal numbers are 1, 5 and 12 (Please see below diagram). The n’th pentagonal number P n is the number of distinct dots in a pattern...
View Articletryexceptpass: The Trusted Packaging Index
The Trusted Packaging Index A proposal for funding PyPI infrastructure and development A few days ago, I was listening to the latest episode of Talk python To Me: Are we failing to fund Python’s core...
View Articlepython学习日记-面向对象编程(一)
python的类(class)和实例(instance) 假设一种鞋子(shoe)有尺码(size)和颜色(color)两种属性,以此为例。 类可以起到模板的作用,因此,可以在创建实例的时候,把一些我们认为必须绑定的属性强制填写进去。通过定义一个特殊的 __init__ 方法,在创建实例的时候,就把 size,color 属性绑到shoe上去,例如: 1 class Shoe(object): 2...
View ArticleA Primer to Django Forms
If you want some interactivity with your users, it all starts with forms. Luckily Django provides some out of the box straightforward solution for us. For this tutorial we are going to do a basic...
View ArticleFlybbertigybbets
“gyb” stands for “Generate Your Boilerplate”. Built in python, it’s part of Swift’s utility suite and is implemented here . Gybbing provides a preprocessorthatautomatesinherently repetitivecode that...
View ArticlePeter Bengtsson: Cope with JSONDecodeError in requests.get().json() in Python...
Suppose you don't know with a hundred percent certainty that an API will respond in with a JSON payload you need to protect yourself. This is how you do it in python 3: import json import requests...
View ArticleParsing and indexing PDF in Python
I have a Doxie Go scanner and I scan all the documents I receive in paper. That's nice, but it creates another problem. All the resulting PDF files have to be named, organized and stored... Doing that...
View ArticleSolving Hackaday’s Crypto Challenge
Although I’ve been to several DEF CONs over the past few years, I’ve never found time to devote to solving the badge. The legendary statusof all the puzzles within are somewhat daunting to me....
View ArticleReactOS 0.4.3 Released with GOG, XBMC and Python 3 Supported
The ReactOS Project is pleased to announce the release of another incremental update, version0.4.3. This would be fourth such release the project has made this year, an indication we hope of the...
View ArticleExploring Asyncio - uvloop, sanic and motor
The asyncio package was introduced in the standard library from python 3.4. The package is still in provisional stage, that is backward compatibility can be broken with future changes. However, the...
View ArticleBT网站-奥修磁力-Python开发爬虫代替.NET
BT网站-奥修磁力-python开发爬虫代替.NET写的爬虫,主要演示访问速度和在一千万左右的HASH记录中索引效率。 奥修磁力下载- http://www.oshoh.com 现在用的是Python +CENTOS 7 系统...
View ArticlePython小白的新手教程(一) -- 【网络课堂】
本文是 python 入门级别的基础知识,包括数据类型和变量、输入输出、字符串和编码、list tuple dict set 、条件判断、循环、函数、切片 迭代 列表生成器 生成器 迭代器等。 参考课程: 廖雪峰的官方网站 慕课网-python入门 参考书籍: 侯爵.《编程小白的第1本 Python 入门书》 前言 Python 是一种相当高级的语言,通过 Python...
View ArticlePython: 携带状态的闭包
在 python 中,函数也是一个对象。因此,我们在定义函数时,可以再嵌套定义一个函数,并将该嵌套函数返回,比如: frommathimportpow defmake_pow(n): definner_func(x):# 嵌套定义了 inner_func returnpow(x, n)# 注意这里引用了外部函数的 n returninner_func# 返回 inner_func 上面的代码中,函数...
View Articlepython基础1
一、python安装 1、下载安装包 https://www.python.org/downloads/ 2、安装 默认安装路径:C:\python27 3、配置环境变量 【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中找到 变量名为Path 的一行,双击】 --> 【Python安装目录追加到变值值中,用 ; 分割】...
View Article第十一章 Python常用内建函数
内建函数,可以直接使用,而不需要import。 在前面章节学过的sorded()、reversed()、range(),filter()、reduce()、map()等内建函数,下面再回顾下及学习一些新的内置函数。 函数 描述 示例 sorded(iterable, cmp=None, key=None, reverse=False) 正序排序可迭代对象,生成新的列表 >>>...
View ArticlePython Web Scraping using Beautiful Soup
Background Let’s assume that we have two competitors selling similar pairs of shoes in the same area. Typically, if a competitor wants to know of another competitor’s pricing, competitor A would...
View ArticleZfec Efficient, portable erasure coding tool
zfec -- efficient, portable erasure coding tool Generate redundant blocks of information such that if some of the blocks are lost then the original data can be recovered from the remaining blocks. This...
View Article第十二章 Python文件操作
12.1 open() open()函数作用是打开文件,返回一个文件对象。 用法格式:open(name[, mode[, buffering[,encoding]]]) -> file object name 文件名 mode 模式,比如以只读方式打开 buffering 缓冲区 encoding 返回数据采用的什么编码,一般utf8或gbk Mode Description r 只读,默认...
View Article