Category Archives: Python

Split by comma and strip whitespace in Python

I would rather end up with whitespace removed like this: I am aware that I could loop through the list and strip() each item but, as this is Python, I’m guessing there’s a quicker, easier and more elegant way of doing it. Use list... Read More | Share it now!

Avro Schema python serialize and deseralize

Seralize and Deseralize avro data with schema ahead import avro.schemafrom avro.datafile import DataFileReader, DataFileWriterfrom avro.io import DatumReader, DatumWriter, BinaryDecoder, BinaryEncoderimport ioclass panAvroDataSchem: def dReader... Read More | Share it now!

‘pip install MySQL-python’ fails with ‘IndexError’ on Mac

By finding out the information that mysql-connector-cmight come to the conclusion that the configuration by brew installation may be incorrect , open the /usr/local/bin/mysql_config script to modify some of the contents of it: change... Read More | Share it now!

Python风格规范

https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_style_rules/ 分号 Tip 不要在行尾加分号,... Read More | Share it now!

python中给程序加锁之fcntl模块的使用

python 中给文件加锁——fcntl模块import fcntl打开一个文件##当前目录下test文件要先存在,如果不存在会报错。或者以写的方式打开f =... Read More | Share it now!

pip installation

https://pip.pypa.io/en/stable/installing/ Do I need to install pip? pip is already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org or if you are working in a Virtual Environment created... Read More | Share it now!

如何测试代码覆盖率:coverage.py 简介

本文作者为 Mike Driscoll,译者为 linkcheng,校对 EarlGrey,是 Python 翻译组完成的第二篇译文。本文为编程派微信公众号首发。 Coverage.py 是一个用来测试代码覆盖率的 Python 第三方库。它起初是由... Read More | Share it now!

pickle模块学习 Python

pickle提供了一个简单的持久化功能。可以将对象以文件的形式存放在磁盘上。 —————————————— pickle.dump(obj,... Read More | Share it now!

python logging模块使用教程

简单使用 #!/usr/local/bin/python # -*- coding:utf-8 -*- import logging logging.debug('debug message') logging.info('info message') logging.warn('warn message') logging.error('error message') logging.critical('critical message')... Read More | Share it now!