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次或多次
热门日志
分类
- Php(101)
- Java(8)
- Mysql(32)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(71)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Html(6)
- Windows(8)
- Message(12)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(11)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)
- about(1)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(30)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- Django(4)
- git(7)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(1)
- 架构(16)
- Vue(1)
最新日志
- Docker 那些事
- 欢迎您关注“刘善海价值分享”微信公众号!
- Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
- Linux vim/vi下backspace(退格键)出现^? 或^H
- python 如何通过subprocess.call调用自定义alias别名
- python2 python3中long类型的区别
- 10 个 Linux 中方便的 Bash 别名
- 'python' engine because the 'c' engine does not support regex separators
- importError c extension: No module named np_datetine not buit
- 四个提高工作效率的小技巧