我以前正在阅读Python文档,并且发现了<>
。这与!=
有什么不同?据我所知,唯一的区别是<>
不能使用字符串。 <>
是否做了一些特别的事情,!=
没有,或者我有两年没有听说过它的原因吗?!= vs <>在Python中?
回答
<>
完全一样的东西为!=
,字符串或任何其他类型:
>>> 'a' <> 'b'
True
>>> 'a' != 'b'
True
然而,<>
已被弃用。它一直是removed from Python 3。改为始终使用!=
。
<>
是过去的遗留物。引述docs
!= can also be written <>, but this is an obsolete usage kept for backwards compatibility only. New code should always use !=.
此外,值得注意的是,Python的3不支持<>
。
是只有我,还是只在mouseover上出现blockquote? – 2013-03-03 14:15:00
对我来说也是一样。 – Femaref 2013-03-03 14:15:14
哦,上面有一个“扰流器”课。有一段时间我在这里没有看到。 – 2013-03-03 14:15:35
运营商<>
仅仅是!=
的弃用版本。
查看从doc。
- 1. <%# %> VS <%= %>
- 2. JSP - “<% … %>”VS“<%= … %>”
- 3. ASP.NET <%= %> vs <%: %>
- 4. <asp:XXXX > vs <%# %>/<%@ %>
- 5. $( '<element> ')VS $(' <element />')jQuery中
- 6. Rails的ERb的最佳实践(<% %> VS <% -%> VS <%- -%>)
- 7. <span> vs <figure> vs <area>
- 8. 在tarray <Byte> VS TB的VS PByteArray
- 9. 的ActionScript MXML <mx:> VS <s:>
- 10. RxJs Observable <string> vs Observable <string[]>
- 11. Expression.LessThan vs LambdaExpression <Func <ParamType,object >>
- 12. WPF ObservableCollection <T> vs BindingList <T>
- 13. <asp:Table> vs html <table>
- 14. <script runat =“server”> vs <% %>
- 15. ArrayList <> vs ArrayList <Integer>
- 16. SortedList <K,V> vs SortedDictionary <K,V> vs词典<K,V>
- 17. <script/> vs <script></script>与webpack和角
- 18. ArrayList <ArrayList <String>> vs ArrayList <Object>
- 19. List <Map <String,String >> vs List <Object>
- 20. git checkout vs git checkout HEAD vs git checkout <CURRENT BRANCH> vs git checkout - <WORKING DIR>
- 21. <img> vs <image> HTML中的标记
- 22. ToList <T>()vs ToList()
- 23. EKEvent <!ExceptionDate!> vs RID
- 24. <%: %> vs Microsoft反XSS库
- 25. ASP.NET - meta:ResourceKey vs <%$ Resources:MyKey%>
- 26. 的IList <mutable_struct> VS mutable_struct []
- 27. Map vs Map <K,V>
- 28. Grails的remoteLink VS <a>
- 29. const vs Func <string>
- 30. typeof(T)vs <T>
另外http://stackoverflow.com/questions/4262638/what-does-the-operator-do-in-python/4262646#4262646 – 2013-03-03 14:14:17
不要使用''''。它是从python 3中删除的。 – StoryTeller 2013-03-03 14:14:24
提示在搜索运算符之前,请用双引号将运算符括起来,这样搜索看起来就像'[python]“!=”“<>”'。这些操作员问题以前一直都会询问,如果正确搜索,会立即弹出。 – 2013-03-03 14:17:33