{"id":1084,"date":"2015-09-22T08:31:58","date_gmt":"2015-09-22T00:31:58","guid":{"rendered":"http:\/\/www.myvoipapp.com\/blogs\/yxh\/?p=1084"},"modified":"2019-02-12T20:11:46","modified_gmt":"2019-02-12T12:11:46","slug":"python%e7%9a%84%e5%b0%8f%e5%9d%91%ef%bc%9au","status":"publish","type":"post","link":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/2015\/09\/22\/python%e7%9a%84%e5%b0%8f%e5%9d%91%ef%bc%9au\/","title":{"rendered":"python\u7684\u5c0f\u5751\uff1a%u"},"content":{"rendered":"<p>\u6700\u8fd1\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6709\u4e00\u5c0f\u5904\u4ee3\u7801\u9700\u8981\u5c06\u4e00\u4e2a\u65e0\u7b26\u53f732\u4f4d\u6574\u6570\u8f6c\u6210\u5b57\u7b26\u4e32\uff0c\u4e8e\u662f\u60f3\u5f53\u7136\u5730\u6309\u7167C\u683c\u5f0f\u5316\u7684\u65b9\u6cd5\uff0c\u91c7\u7528\u4e86\u7c7b\u4f3c\u5199\u6cd5\uff1a<\/p>\n<pre>print \"a=%u\"%-1<\/pre>\n<p>\u672c\u6765\u9884\u671f\u662f\u8f93\u51fa\u5185\u5bb9\u4e3a\uff1a<\/p>\n<pre>a=4294967295<\/pre>\n<p>\u5b9e\u9645\u7ed3\u679c\u5e76\u6ca1\u6709\u8f6c\u5316\u4e3a\u65e0\u7b26\u53f7\u6574\u6570\uff0c\u4ecd\u7136\u91c7\u7528\u4e86\u6709\u7b26\u53f7\u6574\u6570\u65b9\u5f0f\uff1a<\/p>\n<pre>a=-1<\/pre>\n<p>\u4f5c\u4e3a\u4e00\u540dC\/C++\u7a0b\u5e8f\u5458\uff0c\u5bf9\u8fd9\u4e2a\u7ed3\u679c\u81ea\u7136\u611f\u5230\u60ca\u8bb6\u3002\u5f88\u663e\u7136\uff0cpython\u628a%u\u548c%d\u7b49\u540c\u8d77\u6765\u4e86\u3002\u4e8e\u662f\u641c\u4e86\u4e00\u4e0bpython\u7684\u6587\u6863\uff0c\u5728<a href=\"https:\/\/docs.python.org\/2\/library\/stdtypes.html#string-formatting\" target=\"_blank\">\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u7ae0\u8282<\/a>\u4e2d\u6709\u8fd9\u6837\u7684\u63cf\u8ff0\uff1a<\/p>\n<pre>%u Obsolete type \u2013 it is identical to 'd'.<\/pre>\n<p>\u6839\u636e\u8fd9\u6587\u6863\u4e2d\u7684\u5185\u5bb9\uff0c\u53c8\u8fdb\u4e00\u6b65\u627e\u5230\u4e86<a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0237\/\" target=\"_blank\">PEP-0237<\/a>\uff0c\u5176\u4e2d\u53c8\u5f3a\u8c03\u4e86\u8fd9\u70b9\uff1a<\/p>\n<pre>this means that '%u' becomes an alias for '%d'. \u00a0It will eventually be removed.<\/pre>\n<p>\u867d\u7136\u4e0d\u662f\u5f88\u7406\u89e3\u4e3a\u4ec0\u4e48\u91c7\u53d6\u8fd9\u79cd\u505a\u6cd5\uff0c\u4f46\u662f\u5f88\u660e\u663e\uff0c\u5728python\u4ee3\u7801\u4e2d\u4e0d\u5e94\u8be5\u518d\u4f7f\u7528%u\u4e86\uff0c\u8fd9\u4e2a\u683c\u5f0f\u8f6c\u6362\u5b8c\u5168\u7b49\u540c\u4e8e%d\uff0c\u800c\u4e14\u5728\u540e\u7eed\u7684\u7248\u672c\u4e2d\u6709\u53ef\u80fd\u4f1a\u88ab\u5220\u9664\u6389\u3002<\/p>\n<p>\u5728\u7a7a\u95f2\u4e4b\u4f59\uff0c\u53c8\u6316\u4e86\u4e00\u4e0bpython\u7684\u4ee3\u7801\uff0c\u7684\u786e\u4e5f\u53cd\u5e94\u4e86\u4e0a\u8ff0\u5404\u9879\u8bf4\u660e\uff1a<\/p>\n<ul>\n<li>PyString_Format \u51fd\u6570\u4e2d\uff0c&#8217;iduoxX&#8217;\u90fd\u6309\u7167 PyInt \u5904\u7406\uff1b<\/li>\n<li>\u63a5\u7740\u5728 formatint \u51fd\u6570\u4e2d\uff0c\u660e\u786e\u8fdb\u884c\u4ee5\u4e0b\u8f6c\u6362\uff1a<\/li>\n<li>\n<pre>if (x &lt; 0 &amp;&amp; type == 'u') { \r\n    type = 'd'; \r\n}<\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6709\u4e00\u5c0f\u5904\u4ee3\u7801\u9700\u8981\u5c06\u4e00\u4e2a\u65e0\u7b26\u53f732\u4f4d\u6574\u6570\u8f6c\u6210\u5b57\u7b26\u4e32\uff0c\u4e8e\u662f\u60f3\u5f53\u7136\u5730\u6309\u7167C\u683c\u5f0f\u5316\u7684\u65b9\u6cd5\uff0c\u91c7\u7528\u4e86\u7c7b\u4f3c\u5199\u6cd5\uff1a print &#8220;a=%u&#8221;%-1 \u672c\u6765\u9884\u671f\u662f&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.myvoipapp.com\/blogs\/yxh\/2015\/09\/22\/python%e7%9a%84%e5%b0%8f%e5%9d%91%ef%bc%9au\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[450,50,449],"class_list":["post-1084","post","type-post","status-publish","format-standard","hentry","category-6","tag-c","tag-python","tag-449"],"_links":{"self":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/1084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/comments?post=1084"}],"version-history":[{"count":3,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/1084\/revisions"}],"predecessor-version":[{"id":1087,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/1084\/revisions\/1087"}],"wp:attachment":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/media?parent=1084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/categories?post=1084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/tags?post=1084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}