在某些库版本的 python "requirements.txt" 中使用时,“>=”和“~=”有什么区别?

What is difference between ">=" and "~=" when use in python "requirements.txt" for some library version?

>=~= 在 python requirements.txt 中用于某些库时有什么区别?例如 requests >= 2.18.0requests ~= 2.18.0

我都试过了,效果很好

requests >= 2.18.0
requests ~= 2.18.0

任何人都可以向我解释 >=~= 运算符之间的确切区别吗?

安装大于或等于一个版本和小于另一个版本(ordered comparisons):

pip install 'SomeProject>=1,<2'

要安装与特定版本 (compatible releases)兼容的版本:

pip install 'SomeProject~=1.4.2'

两种格式说明符都记录在 PEP 440 – Version Identification and Dependency Specification 中。