{"id":101565,"date":"2026-09-07T00:36:52","date_gmt":"2026-09-06T16:36:52","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/101565.html"},"modified":"2026-09-07T00:36:52","modified_gmt":"2026-09-06T16:36:52","slug":"python%e7%9f%a9%e9%98%b5%e4%b8%89%e9%a2%98%e9%80%9a%e5%85%b3%e7%ac%94%e8%ae%b0%ef%bc%9a%e8%9e%ba%e6%97%8b%e3%80%81%e6%97%8b%e8%bd%ac%e3%80%81%e8%bf%b7%e5%ae%ab%ef%bc%88%e9%99%84%e9%81%bf%e5%9d%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/101565.html","title":{"rendered":"[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09"},"content":{"rendered":"<p>\u9879\u76ee\u5730\u5740&#xff1a;Python_test_3<\/p>\n<h3>\u524d\u8a00<\/h3>\n<p>\u4eca\u5929\u96c6\u4e2d\u653b\u514b\u4e86\u4e09\u9053\u77e9\u9635\u7c7b\u9ad8\u9891\u9898&#xff0c;\u5206\u522b\u662f&#xff1a;<\/p>\n<li>\u87ba\u65cb\u77e9\u9635&#xff08;\u6309\u5c42\u6a21\u62df&#xff0c;\u65b9\u5411\u63a7\u5236&#xff09;<\/li>\n<li>\u77e9\u9635\u65cb\u8f6c&#xff08;\u539f\u5730\u65cb\u8f6c&#xff0c;\u4e24\u6b65\u6cd5&#xff09;<\/li>\n<li>\u8ff7\u5bab\u5bfb\u8def&#xff08;DFS &#043; \u56de\u6eaf \/ \u8fed\u4ee3\u6808 &#043; parent \u5b57\u5178&#xff09;<\/li>\n<p>\u5176\u4e2d\u8ff7\u5bab\u5bfb\u8def\u6700\u8003\u9a8c\u7ec6\u8282&#xff0c;\u4e0b\u9762\u9010\u4e00\u603b\u7ed3\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u87ba\u65cb\u77e9\u9635&#xff08;\u6309\u5c42\u6a21\u62df&#xff09;<\/h3>\n<h4>\u6838\u5fc3\u601d\u8def<\/h4>\n<p>\u7528\u56db\u4e2a\u53d8\u91cf top, bottom, left, right \u8868\u793a\u5f53\u524d\u5c42\u7684\u8fb9\u754c&#xff0c;\u6bcf\u6b21\u6309\u987a\u65f6\u9488\u65b9\u5411\u904d\u5386\u56db\u6761\u8fb9&#xff0c;\u7136\u540e\u6536\u7f29\u8fb9\u754c\u3002<\/p>\n<h4>\u6807\u51c6\u6a21\u677f<\/h4>\n<p>def spiral_order(matrix):<br \/>\n    if not matrix or not matrix[0]:<br \/>\n        return []<br \/>\n    m, n &#061; len(matrix), len(matrix[0])<br \/>\n    top, bottom, left, right &#061; 0, m-1, 0, n-1<br \/>\n    res &#061; []<br \/>\n    while top &lt;&#061; bottom and left &lt;&#061; right:<br \/>\n        # \u4e0a\u8fb9&#xff1a;\u4ece\u5de6\u5230\u53f3<br \/>\n        for j in range(left, right&#043;1):<br \/>\n            res.append(matrix[top][j])<br \/>\n        top &#043;&#061; 1<br \/>\n        # \u53f3\u8fb9&#xff1a;\u4ece\u4e0a\u5230\u4e0b<br \/>\n        for i in range(top, bottom&#043;1):<br \/>\n            res.append(matrix[i][right])<br \/>\n        right -&#061; 1<br \/>\n        # \u4e0b\u8fb9&#xff1a;\u4ece\u53f3\u5230\u5de6&#xff08;\u9700\u8981\u68c0\u67e5 top &lt;&#061; bottom&#xff09;<br \/>\n        if top &lt;&#061; bottom:<br \/>\n            for j in range(right, left-1, -1):<br \/>\n                res.append(matrix[bottom][j])<br \/>\n            bottom -&#061; 1<br \/>\n        # \u5de6\u8fb9&#xff1a;\u4ece\u4e0b\u5230\u4e0a&#xff08;\u9700\u8981\u68c0\u67e5 left &lt;&#061; right&#xff09;<br \/>\n        if left &lt;&#061; right:<br \/>\n            for i in range(bottom, top-1, -1):<br \/>\n                res.append(matrix[i][left])<br \/>\n            left &#043;&#061; 1<br \/>\n    return res <\/p>\n<h4>\u6613\u9519\u70b9<\/h4>\n<ul>\n<li>\u5355\u884c\u6216\u5355\u5217&#xff1a;\u904d\u5386\u4e0b\u8fb9\u548c\u5de6\u8fb9\u524d\u5fc5\u987b\u52a0 if \u5224\u65ad&#xff0c;\u5426\u5219\u4f1a\u91cd\u590d\u904d\u5386\u3002<\/li>\n<li>\u8fb9\u754c\u66f4\u65b0\u987a\u5e8f&#xff1a;\u6bcf\u904d\u5386\u5b8c\u4e00\u8fb9\u7acb\u5373\u66f4\u65b0\u8fb9\u754c&#xff0c;\u4fdd\u8bc1\u4e0b\u4e00\u6b21\u904d\u5386\u7684\u8303\u56f4\u6b63\u786e\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e8c\u3001\u77e9\u9635\u65cb\u8f6c&#xff08;\u539f\u5730\u65cb\u8f6c&#xff09;<\/h3>\n<h4>\u6838\u5fc3\u601d\u8def<\/h4>\n<p>\u4e24\u6b65\u6cd5&#xff1a;\u5148\u4e0a\u4e0b\u7ffb\u8f6c&#xff0c;\u518d\u6cbf\u4e3b\u5bf9\u89d2\u7ebf\u5bf9\u79f0\u4ea4\u6362\u3002<\/p>\n<h4>\u6807\u51c6\u6a21\u677f&#xff08;n\u00d7n \u65b9\u9635&#xff09;<\/h4>\n<p>def rotate(matrix):<br \/>\n    n &#061; len(matrix)<br \/>\n    # 1. \u4e0a\u4e0b\u7ffb\u8f6c<br \/>\n    for i in range(n \/\/ 2):<br \/>\n        matrix[i], matrix[n-1-i] &#061; matrix[n-1-i], matrix[i]<br \/>\n    # 2. \u4e3b\u5bf9\u89d2\u7ebf\u5bf9\u79f0\u4ea4\u6362&#xff08;\u53ea\u904d\u5386\u4e0a\u4e09\u89d2&#xff09;<br \/>\n    for i in range(n):<br \/>\n        for j in range(i&#043;1, n):<br \/>\n            matrix[i][j], matrix[j][i] &#061; matrix[j][i], matrix[i][j] <\/p>\n<h4>\u6613\u9519\u70b9<\/h4>\n<ul>\n<li>\u5bf9\u89d2\u7ebf\u4ea4\u6362\u8303\u56f4&#xff1a;\u5fc5\u987b\u662f j &gt; i&#xff08;\u4e0a\u4e09\u89d2&#xff09;&#xff0c;\u4e0d\u80fd\u904d\u5386\u4e0b\u4e09\u89d2&#xff0c;\u5426\u5219\u4f1a\u91cd\u590d\u4ea4\u6362\u5bfc\u81f4\u8fd8\u539f\u3002<\/li>\n<li>\u4e0a\u4e0b\u7ffb\u8f6c\u7684\u5faa\u73af\u6b21\u6570&#xff1a;n \/\/ 2&#xff0c;\u5947\u6570\u65f6\u4e2d\u95f4\u4e00\u884c\u4e0d\u52a8\u3002<\/li>\n<li>\u539f\u5730\u64cd\u4f5c&#xff1a;\u4e0d\u9700\u8981\u989d\u5916\u77e9\u9635&#xff0c;\u4f46\u9700\u8981\u4e34\u65f6\u53d8\u91cf&#xff08;Python \u5143\u7ec4\u4ea4\u6362\u81ea\u52a8\u5904\u7406&#xff09;\u3002<\/li>\n<\/ul>\n<h4>\u53d8\u4f53<\/h4>\n<ul>\n<li>\u9006\u65f6\u9488\u65cb\u8f6c&#xff1a;\u5148\u5de6\u53f3\u7ffb\u8f6c&#xff0c;\u518d\u4e3b\u5bf9\u89d2\u7ebf\u5bf9\u79f0&#xff1b;\u6216\u5148\u4e0a\u4e0b\u7ffb\u8f6c&#xff0c;\u518d\u526f\u5bf9\u89d2\u7ebf\u5bf9\u79f0\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e09\u3001\u8ff7\u5bab\u5bfb\u8def&#xff08;DFS &#043; parent \u5b57\u5178&#xff09;<\/h3>\n<h4>\u9898\u76ee\u63cf\u8ff0<\/h4>\n<p>\u7ed9\u5b9a m\u00d7n \u7f51\u683c&#xff0c;0 \u53ef\u901a\u884c&#xff0c;1 \u969c\u788d&#xff0c;\u4ece (0,0) \u5230 (m-1,n-1)&#xff0c;\u53ea\u80fd\u5411\u53f3\u6216\u5411\u4e0b&#xff0c;\u8fd4\u56de\u4efb\u610f\u4e00\u6761\u8def\u5f84\u3002<\/p>\n<h4>\u8fed\u4ee3 DFS \u6807\u51c6\u6a21\u677f<\/h4>\n<p>def find_path(grid):<br \/>\n    if not grid or not grid[0]:<br \/>\n        return []<br \/>\n    m, n &#061; len(grid), len(grid[0])<br \/>\n    # \u8d77\u70b9\u6216\u7ec8\u70b9\u662f\u969c\u788d&#xff0c;\u76f4\u63a5\u8fd4\u56de<br \/>\n    if grid[0][0] &#061;&#061; 1 or grid[m-1][n-1] &#061;&#061; 1:<br \/>\n        return []<\/p>\n<p>    stack &#061; [(0, 0)]<br \/>\n    parent &#061; {(0, 0): None}  # \u8bb0\u5f55\u6bcf\u4e2a\u683c\u5b50\u7684\u524d\u9a71<br \/>\n    found &#061; False<\/p>\n<p>    while stack:<br \/>\n        x, y &#061; stack.pop()<br \/>\n        if x &#061;&#061; m-1 and y &#061;&#061; n-1:<br \/>\n            found &#061; True<br \/>\n            break<br \/>\n        # \u53ea\u5411\u53f3\u548c\u5411\u4e0b<br \/>\n        for dx, dy in [(0, 1), (1, 0)]:<br \/>\n            nx, ny &#061; x &#043; dx, y &#043; dy<br \/>\n            # \u6ce8\u610f&#xff1a;\u68c0\u67e5\u65b0\u683c\u5b50\u662f\u5426\u53ef\u901a\u884c&#xff0c;\u4e0d\u662f\u5f53\u524d\u683c\u5b50<br \/>\n            if 0 &lt;&#061; nx &lt; m and 0 &lt;&#061; ny &lt; n and grid[nx][ny] &#061;&#061; 0 and (nx, ny) not in parent:<br \/>\n                parent[(nx, ny)] &#061; (x, y)<br \/>\n                stack.append((nx, ny))<\/p>\n<p>    if not found:<br \/>\n        return []<\/p>\n<p>    # \u56de\u6eaf\u8def\u5f84<br \/>\n    path &#061; []<br \/>\n    cur &#061; (m-1, n-1)<br \/>\n    while cur is not None:<br \/>\n        path.append(cur)<br \/>\n        cur &#061; parent[cur]<br \/>\n    path.reverse()<br \/>\n    return path <\/p>\n<h4>\u26a0\ufe0f \u7ec6\u8282\u9677\u9631&#xff08;\u6700\u5bb9\u6613\u6478\u9519\u7684\u5730\u65b9&#xff09;<\/h4>\n<h5>\u9677\u96311&#xff1a;\u8d77\u70b9\/\u7ec8\u70b9\u7684\u969c\u788d\u68c0\u67e5<\/h5>\n<p># \u274c \u9519\u8bef&#xff1a;\u7528 and<br \/>\nif grid[0][0] &#061;&#061; 1 and grid[m-1][n-1] &#061;&#061; 1:<br \/>\n    return []<br \/>\n# \u2705 \u6b63\u786e&#xff1a;\u7528 or&#xff0c;\u53ea\u8981\u6709\u4e00\u4e2a\u662f\u969c\u788d\u5c31\u8fd4\u56de<br \/>\nif grid[0][0] &#061;&#061; 1 or grid[m-1][n-1] &#061;&#061; 1:<br \/>\n    return [] <\/p>\n<p>\u539f\u56e0&#xff1a;\u8d77\u70b9\u6216\u7ec8\u70b9\u4efb\u4e00\u4e3a\u969c\u788d&#xff0c;\u90fd\u4e0d\u53ef\u80fd\u5230\u8fbe&#xff0c;\u5fc5\u987b\u63d0\u524d\u8fd4\u56de\u3002<\/p>\n<h5>\u9677\u96312&#xff1a;\u90bb\u5c45\u5408\u6cd5\u6027\u68c0\u67e5\u4e2d\u7684 grid \u5224\u65ad<\/h5>\n<p># \u274c \u9519\u8bef&#xff1a;\u68c0\u67e5\u5f53\u524d\u683c\u5b50<br \/>\nif &#8230; and grid[x][y] &#061;&#061; 0 and &#8230;<br \/>\n# \u2705 \u6b63\u786e&#xff1a;\u68c0\u67e5\u65b0\u683c\u5b50<br \/>\nif &#8230; and grid[nx][ny] &#061;&#061; 0 and &#8230; <\/p>\n<p>\u539f\u56e0&#xff1a;\u5f53\u524d\u683c\u5b50 (x,y) \u65e2\u7136\u5728\u6808\u4e2d&#xff0c;\u8bf4\u660e\u5b83\u4e00\u5b9a\u662f\u53ef\u901a\u884c\u7684&#xff08;\u5df2\u901a\u8fc7\u524d\u9762\u7684\u68c0\u67e5&#xff09;\u3002\u6211\u4eec\u9700\u8981\u5224\u65ad\u7684\u662f\u4e0b\u4e00\u6b65\u8981\u53bb\u7684\u683c\u5b50\u662f\u5426\u53ef\u901a\u884c\u3002<\/p>\n<h5>\u9677\u96313&#xff1a;parent \u5b57\u5178\u7684\u521d\u59cb\u5316<\/h5>\n<p># \u6b63\u786e\u5199\u6cd5<br \/>\nparent &#061; {(0, 0): None} <\/p>\n<p>\u539f\u56e0&#xff1a;\u8d77\u70b9\u6ca1\u6709\u524d\u9a71&#xff0c;\u8bbe\u4e3a None\u3002\u56de\u6eaf\u65f6\u4f5c\u4e3a\u7ec8\u6b62\u6761\u4ef6\u3002\u5982\u679c\u6f0f\u6389\u521d\u59cb\u5316&#xff0c;\u56de\u6eaf\u5230\u8d77\u70b9\u65f6\u4f1a\u62a5 KeyError\u3002<\/p>\n<h5>\u9677\u96314&#xff1a;not in parent \u7684\u4f5c\u7528<\/h5>\n<p>if &#8230; and (nx, ny) not in parent: <\/p>\n<p>\u4f5c\u7528&#xff1a;\u9632\u6b62\u91cd\u590d\u8bbf\u95ee\u540c\u4e00\u4e2a\u683c\u5b50\u3002\u56e0\u4e3a\u53ea\u80fd\u5411\u53f3\u5411\u4e0b&#xff0c;\u7406\u8bba\u4e0a\u4e0d\u4f1a\u8d70\u56de\u5934\u8def&#xff0c;\u4f46\u4e3a\u4e86\u907f\u514d\u73af\u5f62\u8def\u5f84\u6216\u91cd\u590d\u5165\u6808&#xff0c;\u52a0\u4e0a\u8fd9\u4e2a\u5224\u65ad\u66f4\u5b89\u5168\u3002\u540c\u65f6&#xff0c;\u5b83\u4e5f\u8d77\u5230\u4e86 visited \u7684\u4f5c\u7528\u3002<\/p>\n<h5>\u9677\u96315&#xff1a;\u8def\u5f84\u56de\u6eaf\u7684\u65b9\u5411<\/h5>\n<p># \u4ece\u7ec8\u70b9\u5f00\u59cb<br \/>\ncur &#061; (m-1, n-1)<br \/>\nwhile cur is not None:<br \/>\n    path.append(cur)<br \/>\n    cur &#061; parent[cur]   # \u8df3\u5230\u524d\u4e00\u4e2a\u683c\u5b50<br \/>\npath.reverse()          # \u53cd\u8f6c\u5f97\u5230\u6b63\u786e\u987a\u5e8f <\/p>\n<p>\u6ce8\u610f&#xff1a;parent \u8bb0\u5f55\u7684\u662f\u201c\u4ece\u54ea\u6765\u201d&#xff0c;\u6240\u4ee5\u56de\u6eaf\u65f6\u662f\u4ece\u7ec8\u70b9\u5012\u7740\u8d70\u5230\u8d77\u70b9&#xff0c;\u6700\u540e\u5fc5\u987b\u53cd\u8f6c\u3002<\/p>\n<h5>\u9677\u96316&#xff1a;\u6808\u7684\u5f39\u51fa\u987a\u5e8f\u5f71\u54cd\u8def\u5f84<\/h5>\n<ul>\n<li>\u4f7f\u7528 stack.pop()&#xff08;\u540e\u8fdb\u5148\u51fa&#xff09;\u662f DFS&#xff0c;\u627e\u5230\u7684\u8def\u5f84\u4e0d\u4e00\u5b9a\u6700\u77ed\u3002<\/li>\n<li>\u5982\u679c\u8981\u6c42\u6700\u77ed\u8def\u5f84&#xff0c;\u5e94\u4f7f\u7528 BFS&#xff08;\u961f\u5217 collections.deque&#xff09;\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<table>\n<tr>\n<p>\u9898\u76ee<\/p>\n<p>\u6838\u5fc3\u6280\u5de7<\/p>\n<p>\u6613\u9519\u70b9<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u87ba\u65cb\u77e9\u9635<\/p>\n<\/td>\n<td>\n<p>\u56db\u8fb9\u754c\u53d8\u91cf &#043; \u65b9\u5411\u5faa\u73af<\/p>\n<\/td>\n<td>\n<p>\u5355\u884c\/\u5355\u5217\u65f6\u7684\u8fb9\u754c\u5224\u65ad<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u77e9\u9635\u65cb\u8f6c<\/p>\n<\/td>\n<td>\n<p>\u4e0a\u4e0b\u7ffb\u8f6c &#043; \u5bf9\u89d2\u7ebf\u4ea4\u6362<\/p>\n<\/td>\n<td>\n<p>\u5bf9\u89d2\u7ebf\u904d\u5386\u8303\u56f4&#xff08;\u4e0a\u4e09\u89d2&#xff09;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u8ff7\u5bab\u5bfb\u8def<\/p>\n<\/td>\n<td>\n<p>\u8fed\u4ee3 DFS &#043; parent \u5b57\u5178<\/p>\n<\/td>\n<td>\n<p>\u8d77\u70b9\/\u7ec8\u70b9\u68c0\u67e5\u3001\u65b0\u683c\u5b50\u5224\u65ad\u3001parent \u521d\u59cb\u5316\u3001\u56de\u6eaf\u53cd\u8f6c<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u77e9\u9635\u7c7b\u9898\u578b\u7684\u5173\u952e\u5728\u4e8e\u8fb9\u754c\u6761\u4ef6\u7684\u5168\u8986\u76d6\u548c\u7ec6\u8282\u7684\u4e25\u8c28\u6027\u3002\u5efa\u8bae\u6bcf\u9053\u9898\u81f3\u5c11\u624b\u5199\u4e09\u904d&#xff0c;\u76f4\u5230\u95ed\u773c\u80fd\u5199\u51fa\u65e0 bug \u7684\u4ee3\u7801\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u7ec3\u4e60\u5efa\u8bae<\/h3>\n<li>\u87ba\u65cb\u77e9\u9635 II&#xff08;\u6309\u87ba\u65cb\u987a\u5e8f\u586b\u5145\u77e9\u9635&#xff09;\u2014\u2014 \u5de9\u56fa\u65b9\u5411\u63a7\u5236\u3002<\/li>\n<li>\u5c9b\u5c7f\u6570\u91cf&#xff08;DFS\/BFS \u8fde\u901a\u5206\u91cf&#xff09;\u2014\u2014 \u5de9\u56fa DFS \u904d\u5386\u3002<\/li>\n<li>\u5355\u8bcd\u641c\u7d22&#xff08;\u77e9\u9635\u4e2d\u627e\u5355\u8bcd&#xff0c;\u56de\u6eaf&#xff09;\u2014\u2014 \u5de9\u56fa\u56de\u6eaf &#043; visited \u7ba1\u7406\u3002<\/li>\n<p>\u795d\u4f60\u8003\u8bd5\u987a\u5229&#xff0c;\u62ff\u4e0b 200 \u5206&#xff01;&#x1f680;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9879\u76ee\u5730\u5740&#xff1a;Python_test_3<br \/>\n\u524d\u8a00<br \/>\n\u4eca\u5929\u96c6\u4e2d\u653b\u514b\u4e86\u4e09\u9053\u77e9\u9635\u7c7b\u9ad8\u9891\u9898&#xff0c;\u5206\u522b\u662f&#xff1a;<br \/>\n\u87ba\u65cb\u77e9\u9635&#xff08;\u6309\u5c42\u6a21\u62df&#xff0c;\u65b9\u5411\u63a7\u5236&#xff09;\u77e9\u9635\u65cb\u8f6c&#xff08;\u539f\u5730\u65cb\u8f6c&#xff0c;\u4e24\u6b65\u6cd5&#xff09;\u8ff7\u5bab\u5bfb\u8def&#xff08;DFS  \u56de\u6eaf \/ \u8fed\u4ee3\u6808  parent \u5b57\u5178&#xff09;<br \/>\n\u5176\u4e2d\u8ff7\u5bab\u5bfb\u8def\u6700\u8003\u9a8c\u7ec6\u8282&#xff0c;\u4e0b\u9762\u9010\u4e00\u603b\u7ed3\u3002 \u4e00\u3001\u87ba\u65cb\u77e9\u9635&#xff08;\u6309\u5c42\u6a21\u62df&#xff09;<br \/>\n\u6838<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,1813,427],"topic":[],"class_list":["post-101565","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-1813","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/101565.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u9879\u76ee\u5730\u5740&#xff1a;Python_test_3 \u524d\u8a00 \u4eca\u5929\u96c6\u4e2d\u653b\u514b\u4e86\u4e09\u9053\u77e9\u9635\u7c7b\u9ad8\u9891\u9898&#xff0c;\u5206\u522b\u662f&#xff1a; \u87ba\u65cb\u77e9\u9635&#xff08;\u6309\u5c42\u6a21\u62df&#xff0c;\u65b9\u5411\u63a7\u5236&#xff09;\u77e9\u9635\u65cb\u8f6c&#xff08;\u539f\u5730\u65cb\u8f6c&#xff0c;\u4e24\u6b65\u6cd5&#xff09;\u8ff7\u5bab\u5bfb\u8def&#xff08;DFS \u56de\u6eaf \/ \u8fed\u4ee3\u6808 parent \u5b57\u5178&#xff09; \u5176\u4e2d\u8ff7\u5bab\u5bfb\u8def\u6700\u8003\u9a8c\u7ec6\u8282&#xff0c;\u4e0b\u9762\u9010\u4e00\u603b\u7ed3\u3002 \u4e00\u3001\u87ba\u65cb\u77e9\u9635&#xff08;\u6309\u5c42\u6a21\u62df&#xff09; \u6838\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/101565.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-06T16:36:52+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101565.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/101565.html\",\"name\":\"[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-06T16:36:52+00:00\",\"dateModified\":\"2026-09-06T16:36:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/101565.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/101565.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101565.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/101565.html","og_locale":"zh_CN","og_type":"article","og_title":"[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u9879\u76ee\u5730\u5740&#xff1a;Python_test_3 \u524d\u8a00 \u4eca\u5929\u96c6\u4e2d\u653b\u514b\u4e86\u4e09\u9053\u77e9\u9635\u7c7b\u9ad8\u9891\u9898&#xff0c;\u5206\u522b\u662f&#xff1a; \u87ba\u65cb\u77e9\u9635&#xff08;\u6309\u5c42\u6a21\u62df&#xff0c;\u65b9\u5411\u63a7\u5236&#xff09;\u77e9\u9635\u65cb\u8f6c&#xff08;\u539f\u5730\u65cb\u8f6c&#xff0c;\u4e24\u6b65\u6cd5&#xff09;\u8ff7\u5bab\u5bfb\u8def&#xff08;DFS \u56de\u6eaf \/ \u8fed\u4ee3\u6808 parent \u5b57\u5178&#xff09; \u5176\u4e2d\u8ff7\u5bab\u5bfb\u8def\u6700\u8003\u9a8c\u7ec6\u8282&#xff0c;\u4e0b\u9762\u9010\u4e00\u603b\u7ed3\u3002 \u4e00\u3001\u87ba\u65cb\u77e9\u9635&#xff08;\u6309\u5c42\u6a21\u62df&#xff09; \u6838","og_url":"https:\/\/www.wsisp.com\/helps\/101565.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-06T16:36:52+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/101565.html","url":"https:\/\/www.wsisp.com\/helps\/101565.html","name":"[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-06T16:36:52+00:00","dateModified":"2026-09-06T16:36:52+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/101565.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/101565.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/101565.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"[Python]\u77e9\u9635\u4e09\u9898\u901a\u5173\u7b14\u8bb0\uff1a\u87ba\u65cb\u3001\u65cb\u8f6c\u3001\u8ff7\u5bab\uff08\u9644\u907f\u5751\u6307\u5357\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=101565"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101565\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=101565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=101565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=101565"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=101565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}