{"id":6426,"date":"2023-09-26T12:18:44","date_gmt":"2023-09-26T04:18:44","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=6426"},"modified":"2023-09-26T12:18:44","modified_gmt":"2023-09-26T04:18:44","slug":"ironpython%e7%94%9f%e6%88%90exe%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/09\/26\/ironpython%e7%94%9f%e6%88%90exe%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f\/","title":{"rendered":"ironpython\u751f\u6210exe\u5982\u4f55\u5b9e\u73b0\u7684\uff1f"},"content":{"rendered":"

IronPython \u662f\u4e00\u4e2a\u5f00\u6e90\u7684 Python \u7f16\u8bd1\u5668\uff0c\u5b83\u53ef\u4ee5\u5c06 Python \u4ee3\u7801\u8f6c\u6362\u4e3a .NET \u6846\u67b6\u7684\u7a0b\u5e8f\uff0c\u4ee5\u4fbf\u5728 Windo\u591a\u4e2ahtml\u505a\u6210exe<\/a>ws \u5e73\u53f0\u4e0a\u8fd0\u884c\u3002\u521b\u5efa\u4e00\u4e2a IronPython \u9879\u76ee\u5e76\u751f\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u7684 .exe \u6587\u4ef6\uff0c\u53ef\u4ee5\u8ba9\u4f60\u7684 Python \u4ee3\u7801\u66f4\u65b9\u4fbf\u5730\u5728 Windows \u7cfb\u7edf\u4e0a\u5206\u4eab\u548c\u90e8\u7f72\u3002<\/p>\n

\u5728\u8fd9\u7bc7\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd IronPython \u7684\u57fa\u672c\u539f\u7406\u4ee5\u53ca\u5982\u4f55\u5c06 IronPython \u751f\u6210 .exe \u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

### IronPython \u7684\u57fa\u672c\u539f\u7406:<\/p>\n

IronPython \u7684\u6838\u5fc3\u673a\u5236\u662f\u5c06 Python \u4ee3\u7801\u7f16\u8bd1\u4e3a .NET Framework \u7684 Common Intermediate Language (CIL) \u4ee3\u7801\u3002CIL \u4ee3\u7801\u662f\u9488\u5bf9 Common Language Runtime (CLR) \u7684\u4e2d\u95f4\u4ee3\u7801\uff0c\u800c CLR \u662f .NET Framework \u7684\u6838\u5fc3\u7ec4\u4ef6\u4e4b\u4e00\u3002<\/p>\n

\u7f16\u8bd1\u4e3a CIL \u4ee3\u7801\u7684\u597d\u5904\u662f\u5b83\u53ef\u4ee5\u81ea\u52a8\u5730\u8f6c\u6362\u4e3a\u76ee\u6807\u8ba1\u7b97\u673a\u7684\u672c\u5730\u673a\u5668\u4ee3\u7801\u3002\u8fd9\u4f7f\u5f97\u751f\u6210\u7684 .exe \u6587\u4ef6\u53ef\u4ee5\u5728\u4efb\u4f55\u5b89\u88c5\u4e86 .NET Framework \u7684 Windows \u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u3002<\/p>\n

### \u5982\u4f55\u4f7f\u7528 IronPython \u751f\u6210 .exe \u6587\u4ef6\u5982\u4f55\u505a\u6210exe<\/a>:<\/p>\n

\u8ba9\u6211\u4eec\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u6f14\u793a\u5982\u4f55\u5c06 IronPython \u9879\u76ee\u751f\u6210\u4e00\u4e2a .exe \u53ef\u6267\u884c\u6587\u4ef6\u3002\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 Python \u5e94\u7528\u7a0b\u5e8f\uff0c\u8be5\u7a0b\u5e8f\u5c06\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\u6253\u5370 \u201cHello, IronPython!\u201d\u3002<\/p>\n

1. \u5b89\u88c5 IronPython:<\/p>\n

\u8bbf\u95ee IronPython \u5b98\u65b9\u7f51\u7ad9\uff08https:\/\/ironpython.net\/ \uff09\u5e76\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u3002\u6309\u7167\u5b89\u88c5\u5411\u5bfc\u7684\u6b65\u9aa4\u5b89\u88c5 IronPython\u3002<\/p>\n

2. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Python \u6587\u4ef6:<\/p>\n

\u5728\u60a8\u7684\u5de5\u4f5c\u76ee\u5f55\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a `hello.py` \u7684\u65b0\u6587\u4ef6\uff0c\u5e76\u5c06\u4ee5\u4e0b\u4ee3\u7801\u6dfb\u52a0\u5230\u6587\u4ef6\u4e2d:<\/p>\n

“`python<\/p>\n

print(“Hello, IronPython!”)<\/p>\n

“`<\/p>\n

3. \u751f\u6210 .exe \u6587\u4ef6:<\/p>\n

\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216 PowerShell\uff0c\u5e76\u5bfc\u822a\u5230 `hello.py` \u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u4f7f\u7528 IronPython \u7f16\u8bd1\u5668 `ipy.exe` \u5c06 Python \u4ee3\u7801\u7f16\u8bd1\u4e3a CIL \u4ee3\u7801\uff1a<\/p>\n

“`<\/p>\n

ipy <\/p>\n

<\/figure>\n<\/p>\n

hello.py \/main:hello.py \/target:exe \/out:hello.exe<\/p>\n

“`<\/p>\n

\u8fd9\u4e2a\u547d\u4ee4\u544a\u8bc9 IronPython \u7f16\u8bd1\u5668\u5c06 `hello.py` \u6587\u4ef6\u7f16\u8bd1\u4e3a `.exe` \u6587\u4ef6\uff0c\u5e76\u5c06\u8f93\u51fa\u6587\u4ef6\u547d\u540d\u4e3a `hello.exe`\u3002<\/p>\n

4. \u6d4b\u8bd5\u751f\u6210\u7684 .exe \u6587\u4ef6:<\/p>\n

\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216 PowerShell \u4e2d\uff0c\u8fd0\u884c\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4ee5\u67e5\u770b\u5176\u8f93\u51fa\uff1a<\/p>\n

“`<\/p>\n

hello.exe<\/p>\n

“`<\/p>\n

\u60a8\u5c06\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\u770b\u5230 “Hello, IronPython!” \u7684\u8f93\u51fa\uff0c\u8bf4\u660e\u751f\u6210\u7684 .exe \u6587\u4ef6\u5df2\u6210\u529f\u8fd0\u884c\u3002<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u4f7f\u7528 IronPython \u751f\u6210\u4e86\u4e00\u4e2a\u53ef\u5728 Windows \u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u7684 .exe \u6587\u4ef6\u3002\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8ba9\u60a8\u8f7b\u677e\u5730\u4e0e\u4e0d\u719f\u6089 Python \u7684\u7528\u6237\u5171\u4eab\u60a8\u7684 Python \u4ee3\u7801\u3002\u4f46\u662f\uff0c\u8bf7\u6ce8\u610f\uff0c\u751f\u6210\u7684 .exe \u6587\u4ef6\u9700\u8981 .NET Framework \u6765\u8fd0\u884c\uff0c\u56e0\u6b64\u786e\u4fdd\u76ee\u6807\u8ba1\u7b97\u673a\u5df2\u5b89\u88c5\u4e86\u9002\u5f53\u7684\u7248\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

IronPython \u662f\u4e00\u4e2a\u5f00\u6e90\u7684 Python \u7f16\u8bd1\u5668\uff0c\u5b83\u53ef\u4ee5\u5c06 Python \u4ee3\u7801\u8f6c\u6362\u4e3a .NET \u6846\u67b6\u7684\u7a0b\u5e8f\uff0c\u4ee5\u4fbf\u5728 Windows \u5e73\u53f0\u4e0a\u8fd0\u884c\u3002\u521b\u5efa\u4e00\u4e2a IronPython \u9879\u76ee\u5e76\u751f\u6210\u4e00\u4e2a<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[38,1032,10864,6812,12],"topic":[],"class_list":{"0":"post-6426","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-zhuomianruanjian","7":"tag-38","8":"tag-1032","9":"tag-exe","11":"tag-12"},"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/6426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=6426"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/6426\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=6426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=6426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=6426"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=6426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}