{"id":30,"date":"2026-01-26T01:57:19","date_gmt":"2026-01-25T17:57:19","guid":{"rendered":"https:\/\/fslbr.cn\/?p=30"},"modified":"2026-01-26T01:57:20","modified_gmt":"2026-01-25T17:57:20","slug":"python3-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b01","status":"publish","type":"post","link":"https:\/\/fslbr.cn\/?p=30","title":{"rendered":"python3 \u5b66\u4e60\u7b14\u8bb01"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u5217\u8868\u7528\u6cd5<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>l = &#91;10, 3.1, 'aaa', &#91;'bbb', 'ccc'], 'ddd']\nprint(l)            # &#91;10, 3.1, 'aaa', &#91;'bbb', 'ccc'], 'ddd']\nprint(l&#91;1])         # 3.1\nprint(l&#91;2])         # aaa\nprint(l&#91;3]&#91;1])      # ccc<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u5b57\u5178\u7528\u6cd5<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>info = {\"name\": '\u5218\u500d\u8363', \"age\": 18, \"gender\": 'male', \"salary\": 19}\nprint(info&#91;'name'])  # \u5218\u500d\u8363<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u5217\u8868+\u5b57\u5178<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>students_info = &#91;\n{'name': '\u5218\u500d\u83630', 'age1': 19, 'gender': '\u5218'},\n{'name': '\u5218\u500d\u83631', 'age1': 19, 'gender': '\u500d'},\n{'name': '\u5218\u500d\u83632', 'age1': 19, 'gender': '\u8363'},\n]\nprint(students_info&#91;1]&#91;'gender'])  # \u500d<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u683c\u5f0f\u5316\u8f93\u51fa %<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>print(\"abc%shij%s\" %(\"def\", 10)) #abcdefhij10<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u683c\u5f0f\u5316\u8f93\u51fa format1<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>a = \"name:{}  age:{}  sex:{} \"\nprint(a.format(\"\u5218\u500d\u8363\", 100, \"male\"))       #name:\u5218\u500d\u8363  age:100  sex:male<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u683c\u5f0f\u5316\u8f93\u51fa format2<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>a = \"name:{x}  age:{y}  sex:{z} \"\nprint(a.format(z=\"male\", y=100, x=\"\u5218\u500d\u8363\")) #name:\u5218\u500d\u8363  age:100  sex:male<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u683c\u5f0f\u5316\u8f93\u51fa f&#8221;<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>x=\"\u5218\u500d\u8363\"\ny=100\nz=\"male\"\nprint(f'name:{x}  age:{y}  sex:{z}')       #name:\u5218\u500d\u8363  age:100  sex:male<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u683c\u5f0f\u5316\u8f93\u51fa f&#8221; {}\u5185\u7684\u5b57\u7b26\u4e32\u53ef\u4ee5\u88ab\u5f53\u4f5c\u8868\u8fbe\u5f0f\u8fd0\u884c\u3002<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>print(f'{100+9}')  # 109<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5217\u8868\u7528\u6cd5 \u5b57\u5178\u7528\u6cd5 \u5217\u8868+\u5b57\u5178 \u683c\u5f0f\u5316\u8f93\u51fa % \u683c\u5f0f\u5316\u8f93\u51fa format1 \u683c\u5f0f\u5316\u8f93\u51fa format2 \u683c\u5f0f\u5316 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/fslbr.cn\/index.php?rest_route=\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fslbr.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fslbr.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fslbr.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fslbr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":1,"href":"https:\/\/fslbr.cn\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":31,"href":"https:\/\/fslbr.cn\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions\/31"}],"wp:attachment":[{"href":"https:\/\/fslbr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fslbr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fslbr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}