安装pip, setuptools, and wheel
-
如果已经从python.org,安装啦Python 2 >=2.7.9 or Python 3 >=3.4 ,那么就已经有啦pip and setuptools, 但是需要升级到最新版本:
On Linux or OS X:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
安装protobuf
-
pip install protobuf
下载源码protocol-buffers
-
https://developers.google.com/protocol-buffers/docs/downloads
-
windows下,需要下载两个包:
Python测试文件保存和读取
-
protoc -I=$SRC_DIR --python_out=$DST_DIR $SRC_DIR/addressbook.proto
-
protoc -I=D:\protobuf-2.6.1\examples --python_out=D:\protobuf-2.6.1\examples D:\protobuf-2.6.1\examples/addressbook.proto,生成addressbook_pb2.py文件。
- cmd执行python add_person.py demo.txt,录入相关信息,保存文件为demo.txt.
- cmd执行python list_people.py demo.txt,现实录入相关信息。
参考:
https://packaging.python.org/installing/#setup-for-installing-packages
http://blog.csdn.net/majianfei1023/article/details/45371743