{"id":41712,"date":"2023-12-11T14:54:21","date_gmt":"2023-12-11T06:54:21","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=41712"},"modified":"2023-12-11T14:54:21","modified_gmt":"2023-12-11T06:54:21","slug":"os%e5%92%8csys%e6%a8%a1%e5%9d%97%e7%9a%84%e4%bd%9c%e7%94%a8%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/os%e5%92%8csys%e6%a8%a1%e5%9d%97%e7%9a%84%e4%bd%9c%e7%94%a8%ef%bc%9f\/","title":{"rendered":"os\u548csys\u6a21\u5757\u7684\u4f5c\u7528\uff1f"},"content":{"rendered":"<p>&#8220;`&#8221;<\/p>\n<p>os\u6a21\u5757\u8d1f\u8d23\u7a0b\u5e8f\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4ea4\u4e92\uff0c\u63d0\u4f9b\u4e86\u8bbf\u95ee\u64cd\u4f5c\u7cfb\u7edf\u5e95\u5c42\u7684\u63a5\u53e3;<br \/>\nsys\u6a21\u5757\u8d1f\u8d23\u7a0b\u5e8f\u4e0epython\u89e3\u91ca\u5668\u7684\u4ea4\u4e92\uff0c\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u51fd\u6570\u548c\u53d8\u91cf\uff0c\u7528\u4e8e\u64cd\u63a7python\u7684\u8fd0\u884c\u65f6\u73af\u5883\u3002<\/p>\n<p>&lt;pre&gt;&lt;code&gt;os\u4e0esys\u6a21\u5757\u7684\u5b98\u65b9\u89e3\u91ca\u5982\u4e0b\uff1a<br \/>\nos: This module provides a portable way of using operating system dependent functionality.<br \/>\n\u8fd9\u4e2a\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u79cd\u65b9\u4fbf\u7684\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u51fd\u6570\u7684\u65b9\u6cd5\u3002<br \/>\nsys: This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter.<br \/>\n\u8fd9\u4e2a\u6a21\u5757\u53ef\u4f9b\u8bbf\u95ee\u7531\u89e3\u91ca\u5668\u4f7f\u7528\u6216\u7ef4\u62a4\u7684\u53d8\u91cf\u548c\u4e0e\u89e3\u91ca\u5668\u8fdb\u884c\u4ea4\u4e92\u7684\u51fd\u6570\u3002<br \/>\nos \u5e38\u7528\u65b9\u6cd5<br \/>\nos.remove() \u5220\u9664\u6587\u4ef6<br \/>\nos.rename() \u91cd\u547d\u540d\u6587\u4ef6<br \/>\nos.walk() \u751f\u6210\u76ee\u5f55\u6811\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u540d<br \/>\nos.chdir() \u6539\u53d8\u76ee\u5f55<br \/>\nos.mkdir\/makedirs \u521b\u5efa\u76ee\u5f55\/\u591a\u5c42\u76ee\u5f55<br \/>\nos.rmdir\/removedirs \u5220\u9664\u76ee\u5f55\/\u591a\u5c42\u76ee\u5f55<br \/>\nos.listdir() \u5217\u51fa\u6307\u5b9a\u76ee\u5f55\u7684\u6587\u4ef6<br \/>\nos.getcwd() \u53d6\u5f97\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55<br \/>\nos.chmod() \u6539\u53d8\u76ee\u5f55\u6743\u9650<br \/>\nos.path.basename() \u53bb\u6389\u76ee\u5f55\u8def\u5f84\uff0c\u8fd4\u56de\u6587\u4ef6\u540d<br \/>\nos.path.dirname() \u53bb\u6389\u6587\u4ef6\u540d\uff0c\u8fd4\u56de\u76ee\u5f55\u8def\u5f84<br \/>\nos.path.join() \u5c06\u5206\u79bb\u7684\u5404\u90e8\u5206\u7ec4\u5408\u6210\u4e00\u4e2a\u8def\u5f84\u540d<br \/>\nos.path.split() \u8fd4\u56de( dirname(), basename())\u5143\u7ec4<br \/>\nos.path.splitext() \u8fd4\u56de (filename, extension) \u5143\u7ec4<br \/>\nos.path.getatime\\ctime\\mtime \u5206\u522b\u8fd4\u56de\u6700\u8fd1\u8bbf\u95ee\u3001\u521b\u5efa\u3001\u4fee\u6539\u65f6\u95f4<br \/>\nos.path.getsize() \u8fd4\u56de\u6587\u4ef6\u5927\u5c0f<br \/>\nos.path.exists() \u662f\u5426\u5b58\u5728<br \/>\nos.path.isabs() \u662f\u5426\u4e3a\u7edd\u5bf9\u8def\u5f84<br \/>\nos.path.isdir() \u662f\u5426\u4e3a\u76ee\u5f55<br \/>\nos.path.isfile() \u662f\u5426\u4e3a\u6587\u4ef6<br \/>\nsys \u5e38\u7528\u65b9\u6cd5<br \/>\nsys.argv \u547d\u4ee4\u884c\u53c2\u6570List\uff0c\u7b2c\u4e00\u4e2a\u5143\u7d20\u662f\u7a0b\u5e8f\u672c\u8eab\u8def\u5f84<br \/>\nsys.modules.keys() \u8fd4\u56de\u6240\u6709\u5df2\u7ecf\u5bfc\u5165\u7684\u6a21\u5757\u5217\u8868<br \/>\nsys.exc_info() \u83b7\u53d6\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u5f02\u5e38\u7c7b,exc_type\u3001exc_value\u3001exc_traceback\u5f53\u524d\u5904\u7406\u7684\u5f02\u5e38\u8be6\u7ec6\u4fe1\u606f<br \/>\nsys.exit(n) \u9000\u51fa\u7a0b\u5e8f\uff0c\u6b63\u5e38\u9000\u51fa\u65f6exit(0)<br \/>\nsys.hexversion \u83b7\u53d6Python\u89e3\u91ca\u7a0b\u5e8f\u7684\u7248\u672c\u503c\uff0c16\u8fdb\u5236\u683c\u5f0f\u5982\uff1a0x020403F0<br \/>\nsys.version \u83b7\u53d6Python\u89e3\u91ca\u7a0b\u5e8f\u7684\u7248\u672c\u4fe1\u606f<br \/>\nsys.maxint \u6700\u5927\u7684Int\u503c<br \/>\nsys.maxunicode \u6700\u5927\u7684Unicode\u503c<br \/>\nsys.modules \u8fd4\u56de\u7cfb\u7edf\u5bfc\u5165\u7684\u6a21\u5757\u5b57\u6bb5\uff0ckey\u662f\u6a21\u5757\u540d\uff0cvalue\u662f\u6a21\u5757<br \/>\nsys.path \u8fd4\u56de\u6a21\u5757\u7684\u641c\u7d22\u8def\u5f84\uff0c\u521d\u59cb\u5316\u65f6\u4f7f\u7528PYTHONPATH\u73af\u5883\u53d8\u91cf\u7684\u503c<br \/>\nsys.platform \u8fd4\u56de\u64cd\u4f5c\u7cfb\u7edf\u5e73\u53f0\u540d\u79f0<br \/>\nsys.stdout \u6807\u51c6\u8f93\u51fa<br \/>\nsys.stdin \u6807\u51c6\u8f93\u5165<br \/>\nsys.stderr \u9519\u8bef\u8f93\u51fa<br \/>\nsys.exc_clear() \u7528\u6765\u6e05\u9664\u5f53\u524d\u7ebf\u7a0b\u6240\u51fa\u73b0\u7684\u5f53\u524d\u7684\u6216\u6700\u8fd1\u7684\u9519\u8bef\u4fe1\u606f<br \/>\nsys.exec_prefix \u8fd4\u56de\u5e73\u53f0\u72ec\u7acb\u7684python\u6587\u4ef6\u5b89\u88c5\u7684\u4f4d\u7f6e<br \/>\nsys.byteorder \u672c\u5730\u5b57\u8282\u89c4\u5219\u7684\u6307\u793a\u5668\uff0cbig-endian\u5e73\u53f0\u7684\u503c\u662f&#039;big&#039;,little-endian\u5e73\u53f0\u7684\u503c\u662f&#039;little&#039;<br \/>\nsys.copyright \u8bb0\u5f55python\u7248\u6743\u76f8\u5173\u7684\u4e1c\u897f<br \/>\nsys.api_version \u89e3\u91ca\u5668\u7684C\u7684API\u7248\u672c<br \/>\n\u603b\u7ed3\uff1a<br \/>\nos\u6a21\u5757\u8d1f\u8d23\u7a0b\u5e8f\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4ea4\u4e92\uff0c\u63d0\u4f9b\u4e86\u8bbf\u95ee\u64cd\u4f5c\u7cfb\u7edf\u5e95\u5c42\u7684\u63a5\u53e3;sys\u6a21\u5757\u8d1f\u8d23\u7a0b\u5e8f\u4e0epython\u89e3\u91ca\u5668\u7684\u4ea4\u4e92\uff0c\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u51fd\u6570\u548c\u53d8\u91cf\uff0c\u7528\u4e8e\u64cd\u63a7python\u7684\u8fd0\u884c\u65f6\u73af\u5883\u3002<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; os\u6a21\u5757\u8d1f\u8d23\u7a0b\u5e8f\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4ea4\u4e92\uff0c\u63d0\u4f9b\u4e86\u8bbf\u95ee\u64cd\u4f5c\u7cfb\u7edf\u5e95\u5c42\u7684\u63a5\u53e3; sys\u6a21\u5757\u8d1f [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-41712","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/41712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=41712"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/41712\/revisions"}],"predecessor-version":[{"id":41713,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/41712\/revisions\/41713"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=41712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=41712"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=41712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}