Mac pip install protobuf 安装失败
Installing collected packages: six, protobufFound existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File "/Users/xiaodu/Library/Python/2.7/lib/python/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Users/xiaodu/Library/Python/2.7/lib/python/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Users/xiaodu/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
Protobuf proto3 与 proto2 区别
这是一篇学习笔记。在粗略的看了 Protobuf 的文档中关于 proto2 和 proto3 的说明后,记录下了几点 proto3 区别于 proto2 的地方。
总的来说,proto3 比 proto2 支持更多语言但 更简洁。去掉了一些复杂的语法和特性,更强调约定而弱化语法。如果是首次使用 Protobuf ,建议使用 proto3 。
1)在第一行非空白非注释行,必须写:
syntax = "proto3";
2)字段规则移除了 “required”,并把 “optional” 改名为 “singular”1;
在 proto2 中 required 也是不推荐使用的。proto3 直接从语法层面上移除了 required 规则。其实可以做的更彻底,把所有字段规则描述都撤销,原来的 repeated 改为在类型或字段名后加一对中括号。这样是不是更简洁?
protobuf 语法简介
1.基本语义
在.proto文件中,最基本的数据类型为message,如其定义所示,由message引导,之后是message类型的名字,之后是由{}包含的各个域(fields)。
required string name = 1; 域字义的一个例子。
required 表示这个域是必需的
optional 该域选,出现0次或1次
repeated 重复出现,0次或多次
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(18)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(37)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(72)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)