安裝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
