A Whirlwind Tour of Python
Bikers making a turn Conceived in the late 1980s as a teaching and scripting language, python has since become an essential tool for many programmers, engineers, researchers, and data scientists...
View ArticlePython的枚举enum模块
在其它常用的编程语言中都有枚举类型,例如:C++。虽然python没有内置枚举类型,但是我们可以使用枚举enum模块。 enum属性: 使用type()查看枚举的类型 使用name显示枚举成员的名字 枚举可以遍历 支持哈希,可以用在字典(dict)或集合(set)中 枚举需要使用类来实现,示例代码: # 枚举模块 import enum # 使用class创建枚举 class...
View ArticleA necklace of tears
The problem is: given a set of objects drawn from several groups, put all of them in a row in a “uniform” way. Whatever that means. For example, suppose we have 21 gemstones: 9 red, 5 blue, 3 green, 2...
View Article梦开始的地方
python 学习之路 目录介绍 python 介绍 python 应用领域 python 优缺点 python 解释器 python 发展史 python 安装 python 程序编写Hello word python变量 python 用户输入 python 数据类型 python 数据运算 python 表达式(if..elif..else) python 表达式(while) python...
View ArticleDeploying NoMAD with Configuration Profiles
It feels a little silly to be so excited about something so simple as NoMAD , but there’s nothing simple about NoMAD behind the scenes. It’s doing a lot of heavy lifting that you’d usually need...
View Article使用Python求解分隙ALOHA最大效率
SymPy是一个符号计算的python库,SymPy支持符号计算、高精度计算、模式匹配、绘图、解方程、微积分、组合数学、离散数学、几何学、概率与统计、物理学等方面的功能。下面我将基于它求解以下两个问题。 当有N个活跃节点的时候,分隙ALOHA的效率为 \(N p (1 - p)^{N - 1}\) ,找出使这个表达式最大化的 p 值。 采用 1 中的p值,计算当 N...
View ArticleAn Intro to the Python Imaging Library / Pillow
The python Imaging Library or PIL allowed you to do image processing in Python. The original author, Fredrik Lundh, wrote one of my favorite Python blogs when I first started learning Python. However...
View ArticlePhilip Semanchuk: Creating PDF Documents Using LibreOffice and Python, Part 3
This is part 3 of a 4-part series on creating PDFs using LibreOffice. You should readpart 1 andpart 2 if you haven’t already. This series is a supplement to a talk I gave at PyOhio 2016 . Here in part...
View ArticleSelf-driving RC cars based on OpenCV
Suiron Machine Learning for RC Cars Prediction visualization (green = actual, blue = prediction) Click the video below to see it in action! Dependencies python 2.7was chosen as it was supported by all...
View ArticleBasic Machine Learning in Python with Scikit-learn
Machine learning has become a hot topic in the last few years and it is for a reason. It provides data analysts with efficientways of extracting information from data, allowing it to be usedfor...
View ArticleHome / Python MySQL Tutorial / Calling MySQL Stored Procedures in Python...
f you are not familiar with mysql stored procedures or want to review it as a refresher, you can follow the MySQL stored procedures tutorial . We will create two stored procedures for the...
View ArticleDealing with database transactions in Django + Celery
Celery is an asynchronous task queue/job queue based on distributed message passing. We are big fans of Celery and it’s an important part of our stack. As with any distributed system, Celery comes...
View ArticleWhy I usepy.test
A question came up in Slack at work recently: “What’s your favorite/recommended unit test framework [for python]?” I gave a brief recommendation at the time, but I thought it’d be worth writing up my...
View Article【Python】配置文件读取
python提供了ConfigParser包来进行配置文件读取。 API: read(filename) 读取ini文件内容 sections() 得到所有的section,并以list的形式返回 options(section) 得到该section的所有option items(section) 得到该section的所有键值对 get(section,option)...
View ArticlePython profiling
Profiling(性能调试)是我一直很感兴趣的一个话题,之前给大家介绍过Datadog这个工具,今天我们来看看python语言中有哪些方法来做Profiling。 Poorman's Profiler 最基础的就是使用 time.time() 来计时,这个方法简单有效,也许所有写过Python代码的人都用过。我们可以创建一个decorator使它用起来更方便。 import time import...
View Article数据崇拜:记亚马逊实体书店一行丨数析工匠简报(10.10)
数据崇拜:记亚马逊实体书店一行 人们习惯了在线的信息与商品消费方式之后,对于数据权威的信任甚至是崇拜早已不是问题,只是它以如此真实和自信的方式展露在我面前的时候,我甚至觉得有些震惊,但没有片刻的质疑…… 数据崇拜,在这里体现得淋漓尽致。而可怕的是,我想不到任何一家其他书店甚至商家可以拥有同样的能力。 Amazon...
View ArticleMicropython+STM32制作加速度传感器无线小车
现在无线控制已经成为了电子科学领域的主流,这次就来教大家做一个主流中的主流--无线控制的小车,先给大家看一下最终的成品演示视频:(小车详细演示视频请参见: http://www.micropython.net.cn 典型实例页面)。 成品图 首先介绍一下需要用到的材料: TPYBoardv102开发板两块 小车底盘一个 LORA无线模块两块 充电宝一个...
View ArticleIntroducing django-perf-rec, our Django performance testing tool
N.B. This is a cross-post from the YPlan tech blog . During PyCon UK I had the opportunity to work on open-sourcing our in-house Django performance testing tool, which has now been released as...
View ArticlePython强化训练笔记(五)――找出多个字典中的公共键
在这个问题中,我们期望得到的结果是找到这三轮比赛中,每轮都进球的球员都有谁。下面用python来模拟一下,先生成一批数据: >>> from random import randint, sample>>> # sample是取样的意思,例如sample('abcde', 2),会在'abcde'这个字符串中随机抽样2个字符出来>>> {x:...
View ArticlePython os module- File operations in Python using python os module
python provides os module which can be used to perform File operations like - create, read, write and delete. Below program performs following operation - 1. Check for a directory and create if it...
View Article