{"id":259,"date":"2025-11-09T21:25:53","date_gmt":"2025-11-09T13:25:53","guid":{"rendered":"https:\/\/www.linerroom.cn\/?p=259"},"modified":"2025-11-09T21:25:54","modified_gmt":"2025-11-09T13:25:54","slug":"%e8%87%aa%e5%86%99python%e6%80%bb%e7%bb%93%ef%bc%88%e5%9f%ba%e7%a1%80%e7%af%87%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.linerroom.cn\/?p=259","title":{"rendered":"\u81ea\u5199python\u603b\u7ed3\uff08\u57fa\u7840\u7bc7\uff09"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.linerroom.cn\/wp-content\/uploads\/2025\/11\/a682d5260b25b57437a1183b74ee8ffb-1024x640.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"640\" data-attachment-id=\"260\" data-permalink=\"https:\/\/www.linerroom.cn\/?attachment_id=260\" data-orig-file=\"https:\/\/i0.wp.com\/www.linerroom.cn\/wp-content\/uploads\/2025\/11\/a682d5260b25b57437a1183b74ee8ffb.png?fit=2560%2C1600&amp;ssl=1\" data-orig-size=\"2560,1600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"a682d5260b25b57437a1183b74ee8ffb\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.linerroom.cn\/wp-content\/uploads\/2025\/11\/a682d5260b25b57437a1183b74ee8ffb.png?fit=300%2C188&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.linerroom.cn\/wp-content\/uploads\/2025\/11\/a682d5260b25b57437a1183b74ee8ffb.png?fit=1024%2C640&amp;ssl=1\" data-original=\"https:\/\/www.linerroom.cn\/wp-content\/uploads\/2025\/11\/a682d5260b25b57437a1183b74ee8ffb-1024x640.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-260\"  sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\"\"\"\n                    \u6ce8\u91ca\n\u5728\u5927\u591a\u6570\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c\u6ce8\u91ca\u90fd\u662f\u4e00\u9879\u5f88\u6709\u7528\u7684\u529f\u80fd\u3002\u672c\u4e66\u524d\u9762\u7f16\u5199\u7684\u7a0b\u5e8f\u4e2d\u90fd\u53ea\u5305\u542bPython\u4ee3\u7801\uff0c\u4f46\u968f\u7740\u7a0b\u5e8f\u8d8a\u6765\u8d8a\u5927\u3001\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\n\u5c31\u5e94\u5728\u5176\u4e2d\u6dfb\u52a0\u8bf4\u660e\uff0c\u5bf9\u4f60\u89e3\u51b3\u95ee\u9898\u7684\u65b9\u6cd5\u8fdb\u884c\u5927\u81f4\u7684\u9610\u8ff0\u3002\u6ce8\u91ca\u8ba9\u4f60\u80fd\u591f\u4f7f\u7528\u81ea\u7136\u8bed\u8a00\u5728\u7a0b\u5e8f\u4e2d\u6dfb\u52a0\u8bf4\u660e\u3002\nhttps:&#47;&#47;www.w3school.com.cn\/python\/python_datatypes.asp\n\u7b26\u53f7\uff1a\u201d\u201c\u201d  A \u201c\u201d\uff0c''' A ''',#A\n\nprint():\u5c06\uff08\uff09\u5185\u7684\u503c\u6253\u5370\u5728\u7535\u8111\u4e0a\uff08\u663e\u793a\u5728\u63a7\u5236\u53f0\uff09\n\u5982\uff1a\nprint(aaa)\n\u63a7\u5236\u53f0_\naaa #\u6253\u5370aaa\u5230\u63a7\u5236\u53f0\u4e0a\n\ninput():\u5728\u63a7\u5236\u53f0\u663e\u793a\u4f60\u8f93\u5165\u7684\u503c\uff08\u503c\u4e3astr\u578b\uff09\u4e00\u822c\u8981\u7ed9\u5b83\u9644\u4e0a\u53d8\u91cf\u5219\u8fd9\u4e2a\u53d8\u91cf\u7684\u503c\u5c31\u662f\u4f60\u8f93\u5165\u90a3\u4e2a\u503c\u7684\u503c\n\u5982\uff1a\na=input(\"\u503c\uff1a\")\nprint\uff08a\uff09\n\u63a7\u5236\u53f0_\n\u503c\uff1aa  #(a\u4e3a\u4f60\u8f93\u5165\u7684\u503c)\na  #a\u4e3a\u4f60\u8f93\u5165\u7684\u503c\u6253\u5370\u5230\u63a7\u5236\u53f0\u4e0a\n\n\n\n\u6587\u672c\u7c7b\u578b\uff1a\tstr         x = \"Hello World\"\n\u6570\u503c\u7c7b\u578b\uff1a\tint     x = 29, float     x = 29.5  , complex     x = 1j\n\u5e8f\u5217\u7c7b\u578b\uff1a\tlist    x = &#91;\"apple\", \"banana\", \"cherry\"]   , tuple     x = (\"apple\", \"banana\", \"cherry\"), range  x=range(1,5)\n\u6620\u5c04\u7c7b\u578b\uff1a\tdict    x = {\"name\" : \"Bill\", \"age\" : 63}\n\u96c6\u5408\u7c7b\u578b\uff1a\tset     x = {\"apple\", \"banana\", \"cherry\"}, frozenset   x = frozenset({\"apple\", \"banana\", \"cherry\"})\n\u5e03\u5c14\u7c7b\u578b\uff1a\tbool    x = True\n\u4e8c\u8fdb\u5236\u7c7b\u578b\uff1a\tbytes   x = b\"Hello\", bytearray   x = bytearray(5), memoryview   x = memoryview(bytes(5))\n\n\u5e38\u7528\u7684\u7c7b\u578bstr float int(\u5c31\u662f\u6587\u5b57\uff0c\u5c0f\u6570\uff0c\u6574\u6570)\nstr\u540d\u5b57\u7b26\u4e32\u578b\uff1a\u662f\u7531\u6570\u5b57\uff0c\u7b26\u53f7\u7b49\u7ec4\u6210\u7684\u503c\u3002\u5e38\u7528\u201d A \u201c\u548c ' D '\uff08A,D\u4e3a\u5b57\u7b26\u4e32\u7684\u503c\uff09\u8868\u793a   \u5982\u201c\u4f60\u597d010\u2014\u2014\u201d\nfloat\u540d\u6d6e\u70b9\u578b\uff1a\u7531\u6574\u6570\u548c\u5c0f\u6570\u5f62\u6210  \u598215.6\nint \u540d\u6574\u578b\uff1a\u6709\u6574\u6570\u7ec4\u6210  \u5982\uff1a544\n\n\u6ce8\u610f\uff1a\n\u4e0a\u9762\u4e09\u79cd\u53ef\u4ee5\u4e92\u76f8\u8f6c\u6362\uff0cpython\u7684\u8ba1\u7b97\u548c\u8fdc\u884c\u90fd\u662f\u8981\u540c\u578b\u8fdb\u884c\u7684\n\u8f6c\u6362\u51fd\u6570\u4e3a str()float()int()\u5206\u522b\u662f\u8f6c\u6362\u6210str\u578b\uff0cfloat\u578b\uff0cint\u578b\n\u5305\u542b\u5143\u7d20\uff1a\nstr\uff1a\u6574\u6570\uff0c\u5c0f\u6570\uff0c\u6587\u5b57\uff0c\u7b26\u53f7\nfloat\uff1a\u5c0f\u6570\uff0c\u6574\u6570\nint:\u6574\u6570\n\u8f6c\u6362\u4e4b\u95f4\u88ab\u8f6c\u6362\u7684\u503c\u7684\u578b\u8981\u7b26\u5408\u8f6c\u6362\u7684\u578b\u7684\u5143\u7d20(1\u79cd\u6216\u8005\u591a\u79cd)\uff0c\u7279\u522b\u662fstr\u4e2d\u6709\u6587\u5b57\u548c\u7b26\u53f7\u65f6\u4e0d\u80fd\u8f6c\u6362\u4e0b\u97622\u79cd\u7c7b\u578b\n\u5982\uff1a\nstr1=\"546\"  #\u5982\u679c\u76f4\u63a5\u6253\u5370\u5219\u63a7\u5236\u53f0\u663e\u793a\u201c546\u201d\u4e0d\u662f546\uff0c546\u4e3astr\nfloat1=16.5\nint1=54\n\nprint(float(str1))\nprint(int(float1)) #\u53ea\u53d6\u6574\u6570\u90e8\u5206\u4e0d\u56db\u820d\u4e94\u5165\nprint(int(strl1))\n\u63a7\u5236\u53f0-\n546.0\n16\n546\n\n\n\"\"\"\n'''#{\n                    \u5b57\u7b26\u4e32\n                \u53d8\u91cf\u7684\u547d\u540d\u548c\u4f7f\u7528\n\u5728Python\u4e2d\u4f7f\u7528\u53d8\u91cf\u65f6\uff0c\u9700\u8981\u9075\u5b88\u4e00\u4e9b\u89c4\u5219\u548c\u6307\u5357\u3002\u8fdd\u53cd\u8fd9\u4e9b\u89c4\u5219\u5c06\u5f15\u53d1\u9519\u8bef\uff0c\u800c\u6307\u5357\u65e8\u5728\u8ba9\u4f60\u7f16\u5199\u7684\u4ee3\u7801\u66f4\u5bb9\u6613\u9605\u8bfb\u548c\u7406\u89e3\u3002\u8bf7\u52a1\u5fc5\u7262\u8bb0\u4e0b\u8ff0\u6709\u5173\u53d8\u91cf\u7684\u89c4\u5219\u3002\n\n\u53d8\u91cf\u540d\u53ea\u80fd\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf\u3002\u53d8\u91cf\u540d\u53ef\u4ee5\u5b57\u6bcd\u6216\u4e0b\u5212\u7ebf\u6253\u5934\uff0c\u4f46\u4e0d\u80fd\u4ee5\u6570\u5b57\u6253\u5934\uff0c\u4f8b\u5982\uff0c\u53ef\u5c06\u53d8\u91cf\u547d\u540d\u4e3amessage_1\uff0c\u4f46\u4e0d\u80fd\u5c06\u5176\u547d\u540d\u4e3a1_message\u3002\n\n\u53d8\u91cf\u540d\u4e0d\u80fd\u5305\u542b\u7a7a\u683c\uff0c\u4f46\u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\u6765\u5206\u9694\u5176\u4e2d\u7684\u5355\u8bcd\u3002\u4f8b\u5982\uff0c\u53d8\u91cf\u540dgreeting_message\u53ef\u884c\uff0c\u4f46\u53d8\u91cf\u540dgreeting message\u4f1a\u5f15\u53d1\u9519\u8bef\u3002\n\n\u4e0d\u8981\u5c06Python\u5173\u952e\u5b57\u548c\u51fd\u6570\u540d\u7528\u4f5c\u53d8\u91cf\u540d\uff0c\u5373\u4e0d\u8981\u4f7f\u7528Python\u4fdd\u7559\u7528\u4e8e\u7279\u6b8a\u7528\u9014\u7684\u5355\u8bcd\uff0c\u5982print\uff08\u8bf7\u53c2\u89c1\u9644\u5f55A.4\uff09\u3002\n\n\u53d8\u91cf\u540d\u5e94\u65e2\u7b80\u77ed\u53c8\u5177\u6709\u63cf\u8ff0\u6027\u3002\u4f8b\u5982\uff0cname\u6bd4n\u597d\uff0cstudent_name\u6bd4s_n\u597d\uff0cname_length\u6bd4length_of_persons_name\u597d\u3002\n\n\u614e\u7528\u5c0f\u5199\u5b57\u6bcdl\u548c\u5927\u5199\u5b57\u6bcdO\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u80fd\u88ab\u4eba\u9519\u770b\u6210\u6570\u5b571\u548c0\u3002\n\n\u8981\u521b\u5efa\u826f\u597d\u7684\u53d8\u91cf\u540d\uff0c\u9700\u8981\u7ecf\u8fc7\u4e00\u5b9a\u7684\u5b9e\u8df5\uff0c\u5728\u7a0b\u5e8f\u590d\u6742\u800c\u6709\u8da3\u65f6\u5c24\u5176\u5982\u6b64\u3002\u968f\u7740\u4f60\u7f16\u5199\u7684\u7a0b\u5e8f\u8d8a\u6765\u8d8a\u591a\uff0c\u5e76\u5f00\u59cb\u9605\u8bfb\u522b\u4eba\u7f16\u5199\u7684\u4ee3\u7801\uff0c\u5c06\u8d8a\u6765\u8d8a\u5584\u4e8e\u521b\u5efa\u6709\u610f\u4e49\u7684\u53d8\u91cf\u540d\u3002\n\n\u6ce8\u610f\u3000\u5c31\u76ee\u524d\u800c\u8a00\uff0c\u5e94\u4f7f\u7528\u5c0f\u5199\u7684Python\u53d8\u91cf\u540d\u3002\u5728\u53d8\u91cf\u540d\u4e2d\u4f7f\u7528\u5927\u5199\u5b57\u6bcd\u867d\u7136\u4e0d\u4f1a\u5bfc\u81f4\u9519\u8bef\uff0c\u4f46\u907f\u514d\u4f7f\u7528\u5927\u5199\u5b57\u6bcd\u662f\u4e2a\u4e0d\u9519\u7684\u4e3b\u610f\u3002\n\n'''\nprint(\"----------------\u5b57\u7b26\u4e32-----------------------             \")\nfirst_name=\"jin\"\nlast_name=\"chan\"\nyou=\"       hello     \"\nname=first_name+last_name\nprint(f\"{first_name},{last_name},hello!\")\nprint(name.title()) #\u5f00\u5934\u5927\u5199\nprint(name.lower()) #\u5168\u90e8\u5927\u5199\nprint(name.upper()) #\u5168\u90e8\u5c0f\u5199\nprint(\"\\tpython\")   #\u8f6c\u4e49\u7b26\\t(\u4e00\u4e2a\u7f29\u8fdb)\nprint(\"(I\\npython\\nis\\nvery good!)\")#\u8f6c\u4e49\u7b26\\n(\u6362\u884c)\nprint(\"hello:\\n\\thi hi hi\")\nprint(you.rstrip())#\u5220\u53bb\u672b\u5c3e\u7a7a\u683c\nprint(you.strip())#\u524d\u540e\u5220\u53bb\u7a7a\u683c\nprint(you.lstrip())#\u5220\u53bb\u5f00\u5934\u7684\u7a7a\u683c\n#}\n\n\n'''#{\n\u6570\n\u6574\u6570\n\u6d6e\u70b9\u6570(\u53ef\u80fd\u4e0d\u786e\u5b9a)\n11!=22  (11\u662f\u6574\u578b\uff0c22\u662f\u5b57\u7b26\u4e32)\n\n'''\nprint(\"         >\u6570&lt;         \")\na,b,c=3,4,5\nprint(a,b,c)    #11\nprint(\"3 4 5\")  #22\nprint(4\/2)\nprint(0.2+0.1)\n#}\n\n'''\n\u5217\u8868\n'''\nprint(\"-------------------------------\u5217\u8868------------------------------------------        \")\n    #\u7d22\u5f15  -4       -3   -2 -1\nlist_1=&#91;\"hello!\",\"by\",\"gfg\",\"d\"]\n    # \u7d22\u5f15   0      1     2   3\nprint(list_1&#91;0].title())\nprint(list_1&#91;-3].upper())\nprint(f\"\u53d8\u5316\u524d\uff1a{list_1}\")\nlist_1&#91;2]=\"hello:\"          #\u4fee\u6539\u7d22\u5f152\u7684\u503c\nprint(f\"\u4fee\u6539\u540e\uff1a{list_1}\")\nlist_1.append(\"sbsbsb\")     #\u6dfb\u52a0sbsbsb\nprint(f\"\u6dfb\u52a0\u540e\uff1a{list_1}\")\nlist_1.insert(1,\"wdasd\")    #\u63d2\u5165wdasd\u5230\u7d22\u5f151\nprint(f\"\u63d2\u5165\u540e\uff1a{list_1}\")\ndel list_1&#91;5]               #\u5220\u53bb\u7d22\u5f155\nprint(f\"\u5220\u53bb\u540e\uff1a{list_1}\")\nsq=list_1.pop()             #\u5220\u53bb\u6700\u540e\u7684\u503c\u5e76\u7ed9\u5b83\u8d4b\u503c\u5230\u5bf9\u8c61sq\nprint(f\"\u53d8\u5316\u540e\uff1a{list_1},\u5220\u53bb\u7684\u503c\uff1a&#91;{sq}]\")\nlist_1.remove(\"by\")         #\u6307\u5b9a\u5220\u9664\u201cby\u201d\nprint(f\"\u5220\u53bb\u540e\uff1a{list_1}\")\nlist_1.sort()               #\u6309\u5b57\u6bcd\u7684\u987a\u5e8f\u6392\u653e\nprint(f\"\u6392\u5e8f\u540e\uff1a{list_1}\")\nlist_1.sort(reverse=True)   #\u6309\u5b57\u6bcd\u7684\u987a\u5e8f\u6765\u5012\u653e(\u6c38\u4e45)\nprint(f\"\u6392\u5e8f\u540e\uff1a{list_1}\")\nprint(f\"1\u6392\u5e8f\u540e\uff1a{sorted(list_1)}\")#\u6309\u5b57\u6bcd\u7684\u987a\u5e8f\u6765\u5012\u653e(\u4e34\u65f6)\nlist_1.reverse()            #\u5012\u7740\u6253\u5217\u8868\nprint(f\"\u6392\u5e8f\u540e\u540e\uff1a{list_1}\")\nprint(f\"\u957f\u5ea6\uff1a{len(list_1)}\u4e2a(\u4e0d\u662f\u5b57\u6bcd\uff1b\u662f\u4ee5,\u95f4\u9694\u7684\u4e2a\u6570)\")\nprint(\"                 \u300b\u300b\u64cd\u4f5c\u5217\u8868\u300a\u300a        \")\n\n\nlist_2=&#91;\"make\",\"jack\",\"nice\",\"because\",\"so\"]\nprint(list_2)\nfor li in list_2:\n    print(f\"list_2:{li}\")\n\nlist_3=&#91;]\nfor i in range(1,11,2):\n    print(f\"\u6dfb\u52a0list_3\uff1a{i}\")\n    list_3.append(i)\n    if i == 9 :\n        print(\"\u5947\u6570\u5df2\u7ecf\u5168\u90e8\u6dfb\u52a0\u5b8c\u6bd5\u3002\u3002\u3002\")\n        print(list_3)\n\n\nlist_4=&#91;]\nfor i in range(1,11):\n    list_4.append(i)\n    if i == 10 :\n        print(f'\u4f20\u7edf\u7684\u65b9\u6cd5\uff1a{list_4}')\n\n\nlist_5=&#91;i for i in range(1,11)]         #@@@@@@\u5217\u8868\u63a8\u5bfc\u5f0f\nprint(f\"\u5217\u8868\u63a8\u5bfc\u5f0f\uff1a{list_5}\")\n\n\nlist_6=list(range(1,11))\nprint(f'\u6570\u5b57\u5217\u8868\uff1a{list_6}')\n\nprint(\"            \u5207 \u7247         \")\nlist_7=&#91;'jk',\"make\",\"mak\",\"akl\",\"ikane\"]\nprint(list_7&#91;2:5])\nprint(list_7&#91;:4])\nprint(list_7&#91;2:])\nlist_7f=list_7&#91;:]\nprint(f\"list_7\u7684\u590d\u5236\u54c1\uff1a{list_7f}\")\n\"\"\"\n\n\n\n                    \u6ce8\u91ca\n\u5728\u5927\u591a\u6570\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c\u6ce8\u91ca\u90fd\u662f\u4e00\u9879\u5f88\u6709\u7528\u7684\u529f\u80fd\u3002\u672c\u4e66\u524d\u9762\u7f16\u5199\u7684\u7a0b\u5e8f\u4e2d\u90fd\u53ea\u5305\u542bPython\u4ee3\u7801\uff0c\u4f46\u968f\u7740\u7a0b\u5e8f\u8d8a\u6765\u8d8a\u5927\u3001\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\n\u5c31\u5e94\u5728\u5176\u4e2d\u6dfb\u52a0\u8bf4\u660e\uff0c\u5bf9\u4f60\u89e3\u51b3\u95ee\u9898\u7684\u65b9\u6cd5\u8fdb\u884c\u5927\u81f4\u7684\u9610\u8ff0\u3002\u6ce8\u91ca\u8ba9\u4f60\u80fd\u591f\u4f7f\u7528\u81ea\u7136\u8bed\u8a00\u5728\u7a0b\u5e8f\u4e2d\u6dfb\u52a0\u8bf4\u660e\u3002\nhttps:\/\/www.w3school.com.cn\/python\/python_datatypes.asp\n\u7b26\u53f7\uff1a\u201d\u201c\u201d  A \u201c\u201d\uff0c''' A ''',#A\n\nprint():\u5c06\uff08\uff09\u5185\u7684\u503c\u6253\u5370\u5728\u7535\u8111\u4e0a\uff08\u663e\u793a\u5728\u63a7\u5236\u53f0\uff09\n\u5982\uff1a\nprint(aaa)\n\u63a7\u5236\u53f0_\naaa #\u6253\u5370aaa\u5230\u63a7\u5236\u53f0\u4e0a\n\ninput():\u5728\u63a7\u5236\u53f0\u663e\u793a\u4f60\u8f93\u5165\u7684\u503c\uff08\u503c\u4e3astr\u578b\uff09\u4e00\u822c\u8981\u7ed9\u5b83\u9644\u4e0a\u53d8\u91cf\u5219\u8fd9\u4e2a\u53d8\u91cf\u7684\u503c\u5c31\u662f\u4f60\u8f93\u5165\u90a3\u4e2a\u503c\u7684\u503c\n\u5982\uff1a\na=input(\"\u503c\uff1a\")\nprint\uff08a\uff09\n\u63a7\u5236\u53f0_\n\u503c\uff1aa  #(a\u4e3a\u4f60\u8f93\u5165\u7684\u503c)\na  #a\u4e3a\u4f60\u8f93\u5165\u7684\u503c\u6253\u5370\u5230\u63a7\u5236\u53f0\u4e0a\n\n\n\n\u6587\u672c\u7c7b\u578b\uff1a\tstr         x = \"Hello World\"\n\u6570\u503c\u7c7b\u578b\uff1a\tint     x = 29, float     x = 29.5  , complex     x = 1j\n\u5e8f\u5217\u7c7b\u578b\uff1a\tlist    x = &#91;\"apple\", \"banana\", \"cherry\"]   , tuple     x = (\"apple\", \"banana\", \"cherry\"), range  x=range(1,5)\n\u6620\u5c04\u7c7b\u578b\uff1a\tdict    x = {\"name\" : \"Bill\", \"age\" : 63}\n\u96c6\u5408\u7c7b\u578b\uff1a\tset     x = {\"apple\", \"banana\", \"cherry\"}, frozenset   x = frozenset({\"apple\", \"banana\", \"cherry\"})\n\u5e03\u5c14\u7c7b\u578b\uff1a\tbool    x = True\n\u4e8c\u8fdb\u5236\u7c7b\u578b\uff1a\tbytes   x = b\"Hello\", bytearray   x = bytearray(5), memoryview   x = memoryview(bytes(5))\n\n\u5e38\u7528\u7684\u7c7b\u578bstr float int(\u5c31\u662f\u6587\u5b57\uff0c\u5c0f\u6570\uff0c\u6574\u6570)\nstr\u540d\u5b57\u7b26\u4e32\u578b\uff1a\u662f\u7531\u6570\u5b57\uff0c\u7b26\u53f7\u7b49\u7ec4\u6210\u7684\u503c\u3002\u5e38\u7528\u201d A \u201c\u548c ' D '\uff08A,D\u4e3a\u5b57\u7b26\u4e32\u7684\u503c\uff09\u8868\u793a   \u5982\u201c\u4f60\u597d010\u2014\u2014\u201d\nfloat\u540d\u6d6e\u70b9\u578b\uff1a\u7531\u6574\u6570\u548c\u5c0f\u6570\u5f62\u6210  \u598215.6\nint \u540d\u6574\u578b\uff1a\u6709\u6574\u6570\u7ec4\u6210  \u5982\uff1a544\n\n\u6ce8\u610f\uff1a\n\u4e0a\u9762\u4e09\u79cd\u53ef\u4ee5\u4e92\u76f8\u8f6c\u6362\uff0cpython\u7684\u8ba1\u7b97\u548c\u8fdc\u884c\u90fd\u662f\u8981\u540c\u578b\u8fdb\u884c\u7684\n\u8f6c\u6362\u51fd\u6570\u4e3a str()float()int()\u5206\u522b\u662f\u8f6c\u6362\u6210str\u578b\uff0cfloat\u578b\uff0cint\u578b\n\u5305\u542b\u5143\u7d20\uff1a\nstr\uff1a\u6574\u6570\uff0c\u5c0f\u6570\uff0c\u6587\u5b57\uff0c\u7b26\u53f7\nfloat\uff1a\u5c0f\u6570\uff0c\u6574\u6570\nint:\u6574\u6570\n\u8f6c\u6362\u4e4b\u95f4\u88ab\u8f6c\u6362\u7684\u503c\u7684\u578b\u8981\u7b26\u5408\u8f6c\u6362\u7684\u578b\u7684\u5143\u7d20(1\u79cd\u6216\u8005\u591a\u79cd)\uff0c\u7279\u522b\u662fstr\u4e2d\u6709\u6587\u5b57\u548c\u7b26\u53f7\u65f6\u4e0d\u80fd\u8f6c\u6362\u4e0b\u97622\u79cd\u7c7b\u578b\n\u5982\uff1a\nstr1=\"546\"  #\u5982\u679c\u76f4\u63a5\u6253\u5370\u5219\u63a7\u5236\u53f0\u663e\u793a\u201c546\u201d\u4e0d\u662f546\uff0c546\u4e3astr\nfloat1=16.5\nint1=54\n\nprint(float(str1))\nprint(int(float1)) #\u53ea\u53d6\u6574\u6570\u90e8\u5206\u4e0d\u56db\u820d\u4e94\u5165\nprint(int(strl1))\n\u63a7\u5236\u53f0-\n546.0\n16\n546\n\n\n\"\"\"\n'''#{\n                    \u5b57\u7b26\u4e32\n                \u53d8\u91cf\u7684\u547d\u540d\u548c\u4f7f\u7528\n\u5728Python\u4e2d\u4f7f\u7528\u53d8\u91cf\u65f6\uff0c\u9700\u8981\u9075\u5b88\u4e00\u4e9b\u89c4\u5219\u548c\u6307\u5357\u3002\u8fdd\u53cd\u8fd9\u4e9b\u89c4\u5219\u5c06\u5f15\u53d1\u9519\u8bef\uff0c\u800c\u6307\u5357\u65e8\u5728\u8ba9\u4f60\u7f16\u5199\u7684\u4ee3\u7801\u66f4\u5bb9\u6613\u9605\u8bfb\u548c\u7406\u89e3\u3002\u8bf7\u52a1\u5fc5\u7262\u8bb0\u4e0b\u8ff0\u6709\u5173\u53d8\u91cf\u7684\u89c4\u5219\u3002\n\n\u53d8\u91cf\u540d\u53ea\u80fd\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf\u3002\u53d8\u91cf\u540d\u53ef\u4ee5\u5b57\u6bcd\u6216\u4e0b\u5212\u7ebf\u6253\u5934\uff0c\u4f46\u4e0d\u80fd\u4ee5\u6570\u5b57\u6253\u5934\uff0c\u4f8b\u5982\uff0c\u53ef\u5c06\u53d8\u91cf\u547d\u540d\u4e3amessage_1\uff0c\u4f46\u4e0d\u80fd\u5c06\u5176\u547d\u540d\u4e3a1_message\u3002\n\n\u53d8\u91cf\u540d\u4e0d\u80fd\u5305\u542b\u7a7a\u683c\uff0c\u4f46\u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\u6765\u5206\u9694\u5176\u4e2d\u7684\u5355\u8bcd\u3002\u4f8b\u5982\uff0c\u53d8\u91cf\u540dgreeting_message\u53ef\u884c\uff0c\u4f46\u53d8\u91cf\u540dgreeting message\u4f1a\u5f15\u53d1\u9519\u8bef\u3002\n\n\u4e0d\u8981\u5c06Python\u5173\u952e\u5b57\u548c\u51fd\u6570\u540d\u7528\u4f5c\u53d8\u91cf\u540d\uff0c\u5373\u4e0d\u8981\u4f7f\u7528Python\u4fdd\u7559\u7528\u4e8e\u7279\u6b8a\u7528\u9014\u7684\u5355\u8bcd\uff0c\u5982print\uff08\u8bf7\u53c2\u89c1\u9644\u5f55A.4\uff09\u3002\n\n\u53d8\u91cf\u540d\u5e94\u65e2\u7b80\u77ed\u53c8\u5177\u6709\u63cf\u8ff0\u6027\u3002\u4f8b\u5982\uff0cname\u6bd4n\u597d\uff0cstudent_name\u6bd4s_n\u597d\uff0cname_length\u6bd4length_of_persons_name\u597d\u3002\n\n\u614e\u7528\u5c0f\u5199\u5b57\u6bcdl\u548c\u5927\u5199\u5b57\u6bcdO\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u80fd\u88ab\u4eba\u9519\u770b\u6210\u6570\u5b571\u548c0\u3002\n\n\u8981\u521b\u5efa\u826f\u597d\u7684\u53d8\u91cf\u540d\uff0c\u9700\u8981\u7ecf\u8fc7\u4e00\u5b9a\u7684\u5b9e\u8df5\uff0c\u5728\u7a0b\u5e8f\u590d\u6742\u800c\u6709\u8da3\u65f6\u5c24\u5176\u5982\u6b64\u3002\u968f\u7740\u4f60\u7f16\u5199\u7684\u7a0b\u5e8f\u8d8a\u6765\u8d8a\u591a\uff0c\u5e76\u5f00\u59cb\u9605\u8bfb\u522b\u4eba\u7f16\u5199\u7684\u4ee3\u7801\uff0c\u5c06\u8d8a\u6765\u8d8a\u5584\u4e8e\u521b\u5efa\u6709\u610f\u4e49\u7684\u53d8\u91cf\u540d\u3002\n\n\u6ce8\u610f\u3000\u5c31\u76ee\u524d\u800c\u8a00\uff0c\u5e94\u4f7f\u7528\u5c0f\u5199\u7684Python\u53d8\u91cf\u540d\u3002\u5728\u53d8\u91cf\u540d\u4e2d\u4f7f\u7528\u5927\u5199\u5b57\u6bcd\u867d\u7136\u4e0d\u4f1a\u5bfc\u81f4\u9519\u8bef\uff0c\u4f46\u907f\u514d\u4f7f\u7528\u5927\u5199\u5b57\u6bcd\u662f\u4e2a\u4e0d\u9519\u7684\u4e3b\u610f\u3002\n\n'''\nprint(\"----------------\u5b57\u7b26\u4e32-----------------------             \")\nfirst_name=\"jin\"\nlast_name=\"chan\"\nyou=\"       hello     \"\nname=first_name+last_name\nprint(f\"{first_name},{last_name},hello!\")\nprint(name.title()) #\u5f00\u5934\u5927\u5199\nprint(name.lower()) #\u5168\u90e8\u5927\u5199\nprint(name.upper()) #\u5168\u90e8\u5c0f\u5199\nprint(\"\\tpython\")   #\u8f6c\u4e49\u7b26\\t(\u4e00\u4e2a\u7f29\u8fdb)\nprint(\"(I\\npython\\nis\\nvery good!)\")#\u8f6c\u4e49\u7b26\\n(\u6362\u884c)\nprint(\"hello:\\n\\thi hi hi\")\nprint(you.rstrip())#\u5220\u53bb\u672b\u5c3e\u7a7a\u683c\nprint(you.strip())#\u524d\u540e\u5220\u53bb\u7a7a\u683c\nprint(you.lstrip())#\u5220\u53bb\u5f00\u5934\u7684\u7a7a\u683c\n#}\n\n\n'''#{\n\u6570\n\u6574\u6570\n\u6d6e\u70b9\u6570(\u53ef\u80fd\u4e0d\u786e\u5b9a)\n11!=22  (11\u662f\u6574\u578b\uff0c22\u662f\u5b57\u7b26\u4e32)\n\n'''\nprint(\"         >\u6570&lt;         \")\na,b,c=3,4,5\nprint(a,b,c)    #11\nprint(\"3 4 5\")  #22\nprint(4\/2)\nprint(0.2+0.1)\n#}\n\n'''\n\u5217\u8868\n'''\nprint(\"-------------------------------\u5217\u8868------------------------------------------        \")\n    #\u7d22\u5f15  -4       -3   -2 -1\nlist_1=&#91;\"hello!\",\"by\",\"gfg\",\"d\"]\n    # \u7d22\u5f15   0      1     2   3\nprint(list_1&#91;0].title())\nprint(list_1&#91;-3].upper())\nprint(f\"\u53d8\u5316\u524d\uff1a{list_1}\")\nlist_1&#91;2]=\"hello:\"          #\u4fee\u6539\u7d22\u5f152\u7684\u503c\nprint(f\"\u4fee\u6539\u540e\uff1a{list_1}\")\nlist_1.append(\"sbsbsb\")     #\u6dfb\u52a0sbsbsb\nprint(f\"\u6dfb\u52a0\u540e\uff1a{list_1}\")\nlist_1.insert(1,\"wdasd\")    #\u63d2\u5165wdasd\u5230\u7d22\u5f151\nprint(f\"\u63d2\u5165\u540e\uff1a{list_1}\")\ndel list_1&#91;5]               #\u5220\u53bb\u7d22\u5f155\nprint(f\"\u5220\u53bb\u540e\uff1a{list_1}\")\nsq=list_1.pop()             #\u5220\u53bb\u6700\u540e\u7684\u503c\u5e76\u7ed9\u5b83\u8d4b\u503c\u5230\u5bf9\u8c61sq\nprint(f\"\u53d8\u5316\u540e\uff1a{list_1},\u5220\u53bb\u7684\u503c\uff1a&#91;{sq}]\")\nlist_1.remove(\"by\")         #\u6307\u5b9a\u5220\u9664\u201cby\u201d\nprint(f\"\u5220\u53bb\u540e\uff1a{list_1}\")\nlist_1.sort()               #\u6309\u5b57\u6bcd\u7684\u987a\u5e8f\u6392\u653e\nprint(f\"\u6392\u5e8f\u540e\uff1a{list_1}\")\nlist_1.sort(reverse=True)   #\u6309\u5b57\u6bcd\u7684\u987a\u5e8f\u6765\u5012\u653e(\u6c38\u4e45)\nprint(f\"\u6392\u5e8f\u540e\uff1a{list_1}\")\nprint(f\"1\u6392\u5e8f\u540e\uff1a{sorted(list_1)}\")#\u6309\u5b57\u6bcd\u7684\u987a\u5e8f\u6765\u5012\u653e(\u4e34\u65f6)\nlist_1.reverse()            #\u5012\u7740\u6253\u5217\u8868\nprint(f\"\u6392\u5e8f\u540e\u540e\uff1a{list_1}\")\nprint(f\"\u957f\u5ea6\uff1a{len(list_1)}\u4e2a(\u4e0d\u662f\u5b57\u6bcd\uff1b\u662f\u4ee5,\u95f4\u9694\u7684\u4e2a\u6570)\")\nprint(\"                 \u300b\u300b\u64cd\u4f5c\u5217\u8868\u300a\u300a        \")\n\n\nlist_2=&#91;\"make\",\"jack\",\"nice\",\"because\",\"so\"]\nprint(list_2)\nfor li in list_2:\n    print(f\"list_2:{li}\")\n\nlist_3=&#91;]\nfor i in range(1,11,2):\n    print(f\"\u6dfb\u52a0list_3\uff1a{i}\")\n    list_3.append(i)\n    if i == 9 :\n        print(\"\u5947\u6570\u5df2\u7ecf\u5168\u90e8\u6dfb\u52a0\u5b8c\u6bd5\u3002\u3002\u3002\")\n        print(list_3)\n\n\nlist_4=&#91;]\nfor i in range(1,11):\n    list_4.append(i)\n    if i == 10 :\n        print(f'\u4f20\u7edf\u7684\u65b9\u6cd5\uff1a{list_4}')\n\n\nlist_5=&#91;i for i in range(1,11)]         #@@@@@@\u5217\u8868\u63a8\u5bfc\u5f0f\nprint(f\"\u5217\u8868\u63a8\u5bfc\u5f0f\uff1a{list_5}\")\n\n\nlist_6=list(range(1,11))\nprint(f'\u6570\u5b57\u5217\u8868\uff1a{list_6}')\n\nprint(\"            \u5207 \u7247         \")\nlist_7=&#91;'jk',\"make\",\"mak\",\"akl\",\"ikane\"]\nprint(list_7&#91;2:5])\nprint(list_7&#91;:4])\nprint(list_7&#91;2:])\nlist_7f=list_7&#91;:]\n(f\"list_7\u7684\u590d\u5236\u54c1\uff1a{list_7f}\")\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>'''\n        \u5b57\u5178\n\n'''\ndictionay_1={\"you\":\"100\",\"he\":\"200\"}\nprint(dictionay_1)\nprint(f\"\u53d8\u5316\u524d\uff1a{dictionay_1}\")\n\nprint(\"you\u7684\u503c\uff1a{}\".format(dictionay_1&#91;\"you\"]))\ndictionay_1&#91;\"she\"]=\"300\"     #\u6dfb\u52a0\u503c\u5230\u5b57\u5178dictionary_1\nprint(f\"\u53d8\u5316\u540e\uff1a{dictionay_1}\")\ndictionay_1&#91;\"you\"]=\"110\"    #\u4fee\u6539you\u7684\u503c\ndel dictionay_1&#91;\"he\"]   #\u5220\u53bbhe\u7684\u503c\nprint(f\"\u5220\u9664\u540e\u7684\u5b57\u5178\uff1a{dictionay_1}\")\nprint(dictionay_1.get(\"dwd\",\"NO have\"))#\u67e5\u770bdwd\u7684\u503c\uff0c\u6ca1\u6709\u8f93\u51faNo have\ndictionay_2={\"dd\":\"Fd\",\"FFF\":\"dd\"}\nfor i,t in dictionay_2.items():\n    print(f\"\\n{i}:{t}\")\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":260,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.linerroom.cn\/wp-content\/uploads\/2025\/11\/a682d5260b25b57437a1183b74ee8ffb.png?fit=2560%2C1600&ssl=1","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=\/wp\/v2\/posts\/259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=259"}],"version-history":[{"count":1,"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":261,"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=\/wp\/v2\/posts\/259\/revisions\/261"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=\/wp\/v2\/media\/260"}],"wp:attachment":[{"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linerroom.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}