{"id":1135,"date":"2024-11-06T19:55:27","date_gmt":"2024-11-06T11:55:27","guid":{"rendered":"https:\/\/gemmartdesign.com\/?p=1135"},"modified":"2024-11-29T22:56:59","modified_gmt":"2024-11-29T14:56:59","slug":"python-post2","status":"publish","type":"post","link":"https:\/\/gemmartdesign.com\/?p=1135","title":{"rendered":"Python\u7df4\u7fd2#2-for\u548cwhile\u8ff4\u5708"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u672c\u5468\u76ee\u6a19<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u719f\u6089Python\u7684\u57fa\u790e\u8a9e\u6cd5\u8207\u8cc7\u6599\u7d50\u69cb<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4efb\u52d9<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b78\u7fd2Python\u57fa\u790e\u8a9e\u6cd5\uff08\u8b8a\u6578\u3001\u6578\u64da\u985e\u578b\u3001\u689d\u4ef6\u8a9e\u53e5\u3001\u8ff4\u5708\uff09<\/li>\n\n\n\n<li>\u4f7f\u7528 if \u689d\u4ef6\u63a7\u5236\u548c for \u8ff4\u5708\u4f86\u505a\u7c21\u55ae\u7684\u6578\u5b78\u8a08\u7b97<\/li>\n\n\n\n<li>\u6df1\u5165\u5b78\u7fd2\u5217\u8868\uff08List\uff09\u3001\u5b57\u5178\uff08Dictionary\uff09\u7b49\u8cc7\u6599\u7d50\u69cb<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c08\u6848\u7df4\u7fd2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528for\u548cwhile\u8ff4\u5708\u9032\u884c\u7c21\u55ae\u7684\u52a0\u7e3d\u904b\u7b97<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">while\u8ff4\u5708<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>n=1\nsum=0\nwhile n&lt;=10:\n    sum=sum+n\n    n+=1\nprint(sum)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">for \u8ff4\u5708<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sum=0\nfor n in range(11):\n    sum=sum+n\nprint(sum)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Output<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>55<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u5468\u76ee\u6a19 \u719f\u6089Python\u7684\u57fa\u790e\u8a9e\u6cd5\u8207\u8cc7\u6599\u7d50\u69cb \u4efb\u52d9 \u5c08\u6848\u7df4&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1249,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","pagelayer_contact_templates":[],"_pagelayer_content":"","_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[9],"tags":[],"class_list":["post-1135","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/1135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1135"}],"version-history":[{"count":2,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/1135\/revisions"}],"predecessor-version":[{"id":1138,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/1135\/revisions\/1138"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/media\/1249"}],"wp:attachment":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}