{"id":3155,"date":"2011-07-10T23:37:23","date_gmt":"2011-07-10T15:37:23","guid":{"rendered":"http:\/\/edsionte.com\/techblog\/?p=3155"},"modified":"2011-07-11T17:53:09","modified_gmt":"2011-07-11T09:53:09","slug":"hellopython","status":"publish","type":"post","link":"http:\/\/edsionte.com\/techblog\/archives\/3155","title":{"rendered":"Hello,Python!"},"content":{"rendered":"<p>\u4f7f\u7528Python\u6253\u5370\u4e00\u6761\u201chello,world\uff01\u201d\u8bed\u53e5\u662f\u518d\u7b80\u5355\u4e0d\u8fc7\u7684\u4e8b\u60c5\u4e86\uff0c\u56e0\u4e3aPython\u7279\u6709\u7684\u4ea4\u4e92\u578b\u89e3\u91ca\u5668\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5b8c\u6210\u8fd9\u9879\u4efb\u52a1\u3002\u5982\u679c\u4f60\u5728Ubuntu\u7cfb\u7edf\u4e0b\uff0c\u9996\u5148\u5728\u7ec8\u7aef\u6572\u5165python\u5c31\u53ef\u4ee5\u8fdb\u5165python\u89e3\u91ca\u5668\uff0c\u7136\u540e\u8f93\u5165&#8221;hello, world!&#8221;\u5373\u53ef\u6253\u5370\u51fa\u8fd9\u53e5\u7ecf\u5178\u7684\u8bed\u53e5\u3002<\/p>\n<pre class=\"brush:c\">edsionte@edsionte-laptop:~$ python\r\nPython 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)\r\n[GCC 4.4.3] on linux2\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n&gt;&gt;&gt; \"hello, world!\"\r\n'hello, world!'<\/pre>\n<p>\u6b64\u65f6\uff0c\u4f60\u5df2\u7ecf\u6210\u529f\u7684\u6253\u5370\u4e86&#8221;hello, world!&#8221;\u8fd9\u6761\u5b57\u7b26\u4e32\u3002\u5f53\u4f60\u8f93\u5165\u8fd9\u6761\u5b57\u7b26\u4e32\u540e\uff0c\u89e3\u91ca\u5668\u5c31\u6309\u7167\u5b57\u7b26\u4e32\u7684\u89e3\u91ca\u89c4\u5219\u53bb\u89e3\u91ca\u5b83\uff0c\u5176\u7ed3\u679c\u5c31\u662f\u5728\u7ec8\u7aef\u663e\u793a\u51fahello, world\u8fd9\u6761\u8bed\u53e5\u3002\u8fd9\u91cc\u7279\u522b\u5f3a\u8c03\u7684\u662f\uff0c\u8fd9\u6761\u8bed\u53e5\u5fc5\u987b\u88ab\u53cc\u5f15\u53f7\u6216\u8005\u5355\u5f15\u53f7\u5305\u62ec\u5728\u5185\uff0c\u5982\u679c\u5728\u89e3\u91ca\u5668\u4e2d\u76f4\u63a5\u8f93\u5165hello, world!\u90a3\u4e48\u5c06\u4f1a\u51fa\u73b0\u8bed\u6cd5\u9519\u8bef\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre class=\"brush:c\">&gt;&gt;&gt; hello, world!\r\n  File \"&lt; stdin &gt;\", line 1\r\n    hello, world!\r\n                ^\r\nSyntaxError: invalid syntax<\/pre>\n<p>\u5176\u4e3b\u8981\u539f\u56e0\u5c31\u662fPython\u89e3\u91ca\u5668\u6b64\u65f6\u4e0d\u77e5\u9053\u5982\u4f55\u89e3\u91ca\u8fd9\u6761\u8bed\u53e5\u3002<\/p>\n<p>\u9664\u4e86\u7528\u53cc\u5f15\u53f7\u6216\u8005\u5355\u5f15\u53f7\u76f4\u63a5\u544a\u8bc9Python\u89e3\u91ca\u5668\u201d\u6b64\u65f6\u4f60\u5e94\u8be5\u89e3\u91ca\u4e00\u6761\u5b57\u7b26\u4e32\u201c\uff0c\u901a\u8fc7print\u547d\u4ee4\u4e5f\u53ef\u4ee5\u6210\u529f\u6253\u5370\u8fd9\u6761\u8bed\u53e5\u3002<\/p>\n<pre class=\"brush:c\">&gt;&gt;&gt; print \"hello, world!\"\r\nhello, world!<\/pre>\n<p>\u81f3\u6b64\uff0c\u4f60\u5df2\u7ecf\u6210\u529f\u7684\u4f7f\u7528Python\u6253\u5370\u4e86\u201chello\uff0cworld\uff01\u201d\uff0c\u4e0d\u8fc7\u8fd9\u4e00\u5207\u90fd\u662f\u5728Python\u89e3\u91ca\u5668\u91cc\u5b8c\u6210\u7684\uff0c\u5f53\u4f60\u9000\u51fa\u89e3\u91ca\u5668\u662f\uff0c\u8fd9\u4e9b\u8bed\u53e5\u5c06\u4f1a\u6d88\u5931\u3002\u6309\u7167\u6211\u4eec\u5e38\u89c4\u7684\u7f16\u7a0b\u4e60\u60ef\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u5c06\u7a0b\u5e8f\u4ee5\u6587\u672c\u7684\u5f62\u5f0f\u4fdd\u5b58\u8d77\u6765\u3002\u6211\u4eec\u4f7f\u7528vim\u521b\u5efa\u4e00\u4e2ahello.py\u7684\u7a0b\u5e8f\uff0c\u5176\u5185\u5bb9\u662f\uff1a<\/p>\n<pre class=\"brush:c\">#!\/usr\/bin\/python2.6\r\nprint \"hello, world!\"<\/pre>\n<p>\u65b0\u589e\u7684\u7b2c\u4e00\u6761\u8bed\u53e5\u544a\u8bc9\u64cd\u4f5c\u7cfb\u7edf\u5e94\u8be5\u4f7f\u7528\/usr\/bin\u76ee\u5f55\u4e0b\u7684Python\u6765\u6267\u884c\u8fd9\u4e9b\u8bed\u53e5\u3002\u6211\u4eec\u518d\u4fee\u6539\u8be5\u6587\u4ef6\u7684\u5c5e\u6027\uff0c\u4f7f\u5b83\u6709\u6267\u884c\u7684\u6743\u9650\u3002\u597d\u4e86\uff0c\u4f60\u5df2\u7ecf\u521b\u5efa\u4e86\u7b2c\u4e00\u4e2aPython\u811a\u672c\uff0c\u73b0\u5728\u5f00\u59cb\u6267\u884c\u5427\uff1a<\/p>\n<pre class=\"brush:c\">edsionte@edsionte-laptop:~\/mypython$ chmod a+x hello.py\r\nedsionte@edsionte-laptop:~\/mypython$ .\/hello.py\r\nhello, world!<\/pre>\n<p>\u6210\u529f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528Python\u6253\u5370\u4e00\u6761\u201chello,world\uff01\u201d\u8bed\u53e5\u662f\u518d\u7b80\u5355\u4e0d\u8fc7\u7684\u4e8b\u60c5\u4e86\uff0c\u56e0\u4e3aPython\u7279\u6709\u7684\u4ea4\u4e92\u578b\u89e3\u91ca [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[232],"tags":[233,234],"class_list":["post-3155","post","type-post","status-publish","format-standard","hentry","category-python","tag-python","tag-234"],"views":6834,"_links":{"self":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/3155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/comments?post=3155"}],"version-history":[{"count":0,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/3155\/revisions"}],"wp:attachment":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/media?parent=3155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/categories?post=3155"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/tags?post=3155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}