{"id":2395,"date":"2015-07-25T17:24:32","date_gmt":"2015-07-25T09:24:32","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2395"},"modified":"2015-07-25T17:24:32","modified_gmt":"2015-07-25T09:24:32","slug":"python%e4%b8%ad-is-%e5%92%8c-%e7%9a%84%e5%8c%ba%e5%88%ab%e5%92%8c%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2395.html","title":{"rendered":"Python\u4e2d is \u548c == \u7684\u533a\u522b\u548c\u7528\u6cd5"},"content":{"rendered":"<h6>\u7f18\u7531\uff1a<\/h6>\n<p><a href=\"http:\/\/www.reddit.com\/r\/Python\/comments\/3a2jlj\/why_you_should_almost_never_use_is_in_python\" target=\"_blank\">http:\/\/www.reddit.com\/r\/Python\/comments\/3a2jlj\/why_you_should_almost_never_use_is_in_python<\/a><\/p>\n<h6>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/h6>\n<p>python is == difference<\/p>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/132988\/is-there-a-difference-between-and-is-in-python\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/132988\/is-there-a-difference-between-and-is-in-python<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/31026754\/python-if-not-vs-if\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/31026754\/python-if-not-vs-if<\/a><\/li>\n<li><a href=\"http:\/\/www.reddit.com\/r\/Python\/comments\/3a2jlj\/why_you_should_almost_never_use_is_in_python\" target=\"_blank\">http:\/\/www.reddit.com\/r\/Python\/comments\/3a2jlj\/why_you_should_almost_never_use_is_in_python<\/a><\/li>\n<\/ul>\n<h6>\u53c2\u8003\u89e3\u7b54\uff1a<\/h6>\n<p>&#8216;is&#8217; will return True if two variables point to <strong><span style=\"color: #ff0000;\">the same object<\/span><\/strong>, &#8216;==&#8221; if the objects referred to by <span style=\"color: #0000ff;\"><strong>the variables are equal<\/strong><\/span>.<\/p>\n<hr \/>\n<p>&#8216;==&#8217; is for value equality. Use it when you would like to know if two objects have the same value.<\/p>\n<p>&#8216;is&#8217; is for reference equality. Use it when you would like to know if two references refer to the same object.<\/p>\n<hr \/>\n<p>&#8216;is&#8217;\u5173\u952e\u5b57\u4e00\u822c\u662f\u7528\u6765\u5224\u65ad\u4e24\u8005\u5f15\u7528\u7684object\u662f\u5426\u4e3a\u540c\u4e00\u4e2a\uff1b<\/p>\n<p>&#8216;==&#8217;\u4e00\u822c\u662f\u7528\u6765\u5224\u65ad\u4e24\u8005\u5f15\u7528\u5bf9\u8c61\u7684\u503c\u662f\u5426\u76f8\u7b49\u3002<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7f18\u7531\uff1a http:\/\/www.reddit.com\/r\/Python\/comments\/3a2jlj\/why_ [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,7],"tags":[540,8],"class_list":["post-2395","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-programing","tag-is","tag-python"],"views":1960,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2395"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2395\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}