{"id":1127542,"date":"2025-01-08T20:11:13","date_gmt":"2025-01-08T12:11:13","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1127542.html"},"modified":"2025-01-08T20:11:15","modified_gmt":"2025-01-08T12:11:15","slug":"python-%e5%a6%82%e4%bd%95%e6%8a%8a%e4%b8%80%e4%b8%aa%e6%95%b4%e6%95%b0%e6%8b%86%e5%88%86%e5%bc%80%e6%9d%a5","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1127542.html","title":{"rendered":"python \u5982\u4f55\u628a\u4e00\u4e2a\u6574\u6570\u62c6\u5206\u5f00\u6765"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25094526\/f8865104-8dec-4399-a400-64e250f22f49.webp\" alt=\"python \u5982\u4f55\u628a\u4e00\u4e2a\u6574\u6570\u62c6\u5206\u5f00\u6765\" \/><\/p>\n<p><p> <strong>Python \u5982\u4f55\u628a\u4e00\u4e2a\u6574\u6570\u62c6\u5206\u5f00\u6765<\/strong>  <\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u628a\u4e00\u4e2a\u6574\u6570\u62c6\u5206\u6210\u5355\u4e2a\u6570\u5b57\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec<strong>\u4f7f\u7528\u5b57\u7b26\u4e32\u8f6c\u6362\u3001\u901a\u8fc7\u6570\u5b66\u8fd0\u7b97\u3001\u9012\u5f52\u65b9\u6cd5<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u5b57\u7b26\u4e32\u8f6c\u6362\u662f\u6700\u7b80\u5355\u548c\u76f4\u89c2\u7684\u65b9\u6cd5\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u5c55\u793a\u5982\u4f55\u5728\u4e0d\u540c\u573a\u666f\u4e2d\u5e94\u7528\u5b83\u4eec\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u5b57\u7b26\u4e32\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u5b57\u7b26\u4e32\u8f6c\u6362\u65b9\u6cd5\u662f\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u4e4b\u4e00\u3002\u6211\u4eec\u9996\u5148\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u518d\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u8f6c\u6362\u4e3a\u5355\u4e2a\u6570\u5b57\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def split_integer_to_digits(n):<\/p>\n<p>    return [int(digit) for digit in str(n)]<\/p>\n<h2><strong>\u793a\u4f8b<\/strong><\/h2>\n<p>number = 12345<\/p>\n<p>digits = split_integer_to_digits(number)<\/p>\n<p>print(digits)  # \u8f93\u51fa: [1, 2, 3, 4, 5]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u4f18\u70b9\uff1a<\/h4>\n<\/p>\n<ol>\n<li><strong>\u7b80\u5355\u76f4\u89c2<\/strong>\uff1a\u4ee3\u7801\u5bb9\u6613\u7406\u89e3\uff0c\u4e0d\u9700\u8981\u590d\u6742\u7684\u6570\u5b66\u8fd0\u7b97\u3002<\/li>\n<li><strong>\u6548\u7387\u9ad8<\/strong>\uff1a\u5bf9\u4e8e\u5927\u591a\u6570\u65e5\u5e38\u5e94\u7528\u573a\u666f\uff0c\u8fd9\u79cd\u65b9\u6cd5\u8db3\u591f\u9ad8\u6548\u3002<\/li>\n<\/ol>\n<p><h4>\u7f3a\u70b9\uff1a<\/h4>\n<\/p>\n<ol>\n<li><strong>\u4f9d\u8d56\u4e8e\u5b57\u7b26\u4e32\u64cd\u4f5c<\/strong>\uff1a\u5728\u67d0\u4e9b\u4e25\u683c\u6027\u80fd\u8981\u6c42\u7684\u573a\u666f\u4e2d\uff0c\u5b57\u7b26\u4e32\u64cd\u4f5c\u53ef\u80fd\u4e0d\u5982\u76f4\u63a5\u7684\u6570\u5b66\u8fd0\u7b97\u9ad8\u6548\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u901a\u8fc7\u6570\u5b66\u8fd0\u7b97<\/h3>\n<\/p>\n<p><p>\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u901a\u8fc7\u6570\u5b66\u8fd0\u7b97\u5c06\u6574\u6570\u62c6\u5206\u4e3a\u5355\u4e2a\u6570\u5b57\u3002\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4f9d\u8d56\u5b57\u7b26\u4e32\u64cd\u4f5c\uff0c\u9002\u7528\u4e8e\u4e00\u4e9b\u5bf9\u6027\u80fd\u8981\u6c42\u8f83\u9ad8\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528\u5faa\u73af\u548c\u6a21\u8fd0\u7b97<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5faa\u73af\u548c\u6a21\u8fd0\u7b97\u6765\u9010\u4e2a\u63d0\u53d6\u6574\u6570\u7684\u6bcf\u4e00\u4f4d\u6570\u5b57\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def split_integer_to_digits(n):<\/p>\n<p>    digits = []<\/p>\n<p>    while n &gt; 0:<\/p>\n<p>        digits.append(n % 10)<\/p>\n<p>        n = n \/\/ 10<\/p>\n<p>    digits.reverse()<\/p>\n<p>    return digits<\/p>\n<h2><strong>\u793a\u4f8b<\/strong><\/h2>\n<p>number = 12345<\/p>\n<p>digits = split_integer_to_digits(number)<\/p>\n<p>print(digits)  # \u8f93\u51fa: [1, 2, 3, 4, 5]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u4f7f\u7528\u9012\u5f52\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>\u9012\u5f52\u65b9\u6cd5\u4e5f\u662f\u4e00\u79cd\u6709\u6548\u7684\u65b9\u5f0f\uff0c\u5c24\u5176\u9002\u5408\u5728\u67d0\u4e9b\u9012\u5f52\u7b97\u6cd5\u4e2d\u5e94\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def split_integer_to_digits(n):<\/p>\n<p>    if n &lt; 10:<\/p>\n<p>        return [n]<\/p>\n<p>    else:<\/p>\n<p>        return split_integer_to_digits(n \/\/ 10) + [n % 10]<\/p>\n<h2><strong>\u793a\u4f8b<\/strong><\/h2>\n<p>number = 12345<\/p>\n<p>digits = split_integer_to_digits(number)<\/p>\n<p>print(digits)  # \u8f93\u51fa: [1, 2, 3, 4, 5]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u4f18\u70b9\uff1a<\/h4>\n<\/p>\n<ol>\n<li><strong>\u65e0\u9700\u5b57\u7b26\u4e32\u64cd\u4f5c<\/strong>\uff1a\u9002\u5408\u5bf9\u6027\u80fd\u6709\u4e25\u683c\u8981\u6c42\u7684\u5e94\u7528\u573a\u666f\u3002<\/li>\n<li><strong>\u7075\u6d3b<\/strong>\uff1a\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8c03\u6574\u5faa\u73af\u6216\u9012\u5f52\u7684\u5b9e\u73b0\u65b9\u5f0f\u3002<\/li>\n<\/ol>\n<p><h4>\u7f3a\u70b9\uff1a<\/h4>\n<\/p>\n<ol>\n<li><strong>\u4ee3\u7801\u590d\u6742\u5ea6\u8f83\u9ad8<\/strong>\uff1a\u76f8\u6bd4\u5b57\u7b26\u4e32\u65b9\u6cd5\uff0c\u4ee3\u7801\u53ef\u80fd\u4e0d\u5982\u5b57\u7b26\u4e32\u8f6c\u6362\u65b9\u6cd5\u76f4\u89c2\u3002<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u4e0d\u540c\u7684\u65b9\u6cd5\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u4ecb\u7ecd\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\uff0c\u5e76\u8bf4\u660e\u54ea\u79cd\u65b9\u6cd5\u66f4\u9002\u5408\u8fd9\u4e9b\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h4>1. \u6570\u636e\u5206\u6790\u548c\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u8fc7\u7a0b\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u5c06\u6574\u6570\u62c6\u5206\u4e3a\u5355\u4e2a\u6570\u5b57\u8fdb\u884c\u7edf\u8ba1\u6216\u5206\u6790\u3002\u6b64\u65f6\uff0c<strong>\u5b57\u7b26\u4e32\u8f6c\u6362\u65b9\u6cd5<\/strong>\u901a\u5e38\u662f\u6700\u7b80\u5355\u548c\u9ad8\u6548\u7684\u9009\u62e9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def count_digits_occurrences(n):<\/p>\n<p>    digits = split_integer_to_digits(n)<\/p>\n<p>    occurrences = [0] * 10<\/p>\n<p>    for digit in digits:<\/p>\n<p>        occurrences[digit] += 1<\/p>\n<p>    return occurrences<\/p>\n<h2><strong>\u793a\u4f8b<\/strong><\/h2>\n<p>number = 1234554321<\/p>\n<p>occurrences = count_digits_occurrences(number)<\/p>\n<p>print(occurrences)  # \u8f93\u51fa: [0, 2, 2, 2, 2, 2, 0, 0, 0, 0]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u6570\u5b57\u6e38\u620f\u548c\u8c1c\u9898<\/h4>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u6570\u5b57\u6e38\u620f\u548c\u8c1c\u9898\u4e2d\uff0c\u9700\u8981\u5c06\u6574\u6570\u62c6\u5206\u4e3a\u5355\u4e2a\u6570\u5b57\u8fdb\u884c\u8ba1\u7b97\u6216\u6bd4\u8f83\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9<strong>\u5b57\u7b26\u4e32\u8f6c\u6362\u65b9\u6cd5<\/strong>\u6216<strong>\u6570\u5b66\u8fd0\u7b97\u65b9\u6cd5<\/strong>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def is_palindrome_number(n):<\/p>\n<p>    digits = split_integer_to_digits(n)<\/p>\n<p>    return digits == digits[::-1]<\/p>\n<h2><strong>\u793a\u4f8b<\/strong><\/h2>\n<p>number = 12321<\/p>\n<p>print(is_palindrome_number(number))  # \u8f93\u51fa: True<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u6027\u80fd\u654f\u611f\u7684\u5e94\u7528<\/h4>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u5bf9\u6027\u80fd\u8981\u6c42\u8f83\u9ad8\u7684\u5e94\u7528\u4e2d\uff0c\u4f8b\u5982\u5d4c\u5165\u5f0f\u7cfb\u7edf\u6216\u9ad8\u6027\u80fd\u8ba1\u7b97\uff0c\u53ef\u80fd\u9700\u8981\u5c3d\u91cf\u907f\u514d\u5b57\u7b26\u4e32\u64cd\u4f5c\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9<strong>\u6570\u5b66\u8fd0\u7b97\u65b9\u6cd5<\/strong>\u6216<strong>\u9012\u5f52\u65b9\u6cd5<\/strong>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def split_integer_to_digits_optimized(n):<\/p>\n<p>    digits = []<\/p>\n<p>    while n &gt; 0:<\/p>\n<p>        digits.append(n % 10)<\/p>\n<p>        n = n \/\/ 10<\/p>\n<p>    digits.reverse()<\/p>\n<p>    return digits<\/p>\n<h2><strong>\u793a\u4f8b<\/strong><\/h2>\n<p>number = 987654321<\/p>\n<p>digits = split_integer_to_digits_optimized(number)<\/p>\n<p>print(digits)  # \u8f93\u51fa: [9, 8, 7, 6, 5, 4, 3, 2, 1]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u7efc\u5408\u6bd4\u8f83\u4e0e\u9009\u62e9<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u9700\u6c42\u548c\u5e94\u7528\u573a\u666f\u3002\u4e0b\u9762\u662f\u5bf9\u4e0a\u8ff0\u65b9\u6cd5\u7684\u7efc\u5408\u6bd4\u8f83\uff1a<\/p>\n<\/p>\n<table>\n<thead>\n<tr>\n<p><th>\u65b9\u6cd5<\/th>\n<\/p>\n<p><th>\u4f18\u70b9<\/th>\n<\/p>\n<p><th>\u7f3a\u70b9<\/th>\n<\/p>\n<p><th>\u9002\u7528\u573a\u666f<\/th>\n<\/p>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<p><td>\u5b57\u7b26\u4e32\u8f6c\u6362\u65b9\u6cd5<\/td>\n<\/p>\n<p><td>\u7b80\u5355\u76f4\u89c2\u3001\u4ee3\u7801\u6613\u8bfb<\/td>\n<\/p>\n<p><td>\u4f9d\u8d56\u5b57\u7b26\u4e32\u64cd\u4f5c<\/td>\n<\/p>\n<p><td>\u6570\u636e\u5206\u6790\u3001\u5904\u7406\u4e00\u822c\u5e94\u7528\u573a\u666f<\/td>\n<\/p>\n<\/tr>\n<tr>\n<p><td>\u5faa\u73af\u548c\u6a21\u8fd0\u7b97\u65b9\u6cd5<\/td>\n<\/p>\n<p><td>\u9ad8\u6548\u3001\u4e0d\u4f9d\u8d56\u5b57\u7b26\u4e32\u64cd\u4f5c<\/td>\n<\/p>\n<p><td>\u4ee3\u7801\u590d\u6742\u5ea6\u8f83\u9ad8<\/td>\n<\/p>\n<p><td>\u6027\u80fd\u654f\u611f\u7684\u5e94\u7528\u3001\u9700\u8981\u907f\u514d\u5b57\u7b26\u4e32\u64cd\u4f5c\u7684\u573a\u666f<\/td>\n<\/p>\n<\/tr>\n<tr>\n<p><td>\u9012\u5f52\u65b9\u6cd5<\/td>\n<\/p>\n<p><td>\u9002\u5408\u9012\u5f52\u7b97\u6cd5\u3001\u4ee3\u7801\u7b80\u6d01<\/td>\n<\/p>\n<p><td>\u53ef\u80fd\u5b58\u5728\u6808\u6ea2\u51fa\u98ce\u9669<\/td>\n<\/p>\n<p><td>\u9012\u5f52\u7b97\u6cd5\u3001\u7279\u5b9a\u6570\u5b66\u95ee\u9898<\/td>\n<\/p>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><h3>\u4e94\u3001\u7ed3\u8bba<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u5c06\u4e00\u4e2a\u6574\u6570\u62c6\u5206\u4e3a\u5355\u4e2a\u6570\u5b57\u7684\u65b9\u6cd5\u591a\u79cd\u591a\u6837\u3002\u6839\u636e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u548c\u9700\u6c42\uff0c\u53ef\u4ee5\u9009\u62e9<strong>\u5b57\u7b26\u4e32\u8f6c\u6362\u65b9\u6cd5\u3001\u5faa\u73af\u548c\u6a21\u8fd0\u7b97\u65b9\u6cd5\u6216\u9012\u5f52\u65b9\u6cd5<\/strong>\u3002<strong>\u5b57\u7b26\u4e32\u8f6c\u6362\u65b9\u6cd5<\/strong>\u9002\u5408\u5927\u591a\u6570\u65e5\u5e38\u5e94\u7528\u573a\u666f\uff0c<strong>\u5faa\u73af\u548c\u6a21\u8fd0\u7b97\u65b9\u6cd5<\/strong>\u548c<strong>\u9012\u5f52\u65b9\u6cd5<\/strong>\u5219\u9002\u5408\u5bf9\u6027\u80fd\u6709\u4e25\u683c\u8981\u6c42\u6216\u7279\u5b9a\u9012\u5f52\u7b97\u6cd5\u7684\u5e94\u7528\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u5408\u7406\u9009\u62e9\u548c\u7075\u6d3b\u5e94\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5c06\u6709\u52a9\u4e8e\u63d0\u9ad8\u4ee3\u7801\u7684\u6548\u7387\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u8be6\u7ec6\u4ecb\u7ecd\u548c\u5b9e\u4f8b\u6f14\u793a\uff0c\u76f8\u4fe1\u60a8\u5df2\u7ecf\u638c\u63e1\u4e86\u5982\u4f55\u5728Python\u4e2d\u5c06\u4e00\u4e2a\u6574\u6570\u62c6\u5206\u4e3a\u5355\u4e2a\u6570\u5b57\u7684\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u60a8\u7684\u5f00\u53d1\u5de5\u4f5c\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5c06\u4e00\u4e2a\u6574\u6570\u8f6c\u6362\u4e3a\u5355\u4e2a\u6570\u5b57\u7684\u5217\u8868\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5355\u4e2a\u6570\u5b57\u3002\u9996\u5148\uff0c\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u5c06\u6bcf\u4e2a\u5b57\u7b26\u8f6c\u6362\u56de\u6574\u6570\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">number = 12345\ndigits = [int(digit) for digit in str(number)]\nprint(digits)  # \u8f93\u51fa: [1, 2, 3, 4, 5]\n<\/code><\/pre>\n<p><strong>\u5982\u4f55\u5c06\u6574\u6570\u62c6\u5206\u4e3a\u4e24\u4e2a\u90e8\u5206\uff0c\u4f8b\u5982\u9ad8\u4f4d\u548c\u4f4e\u4f4d\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7\u6570\u5b66\u8fd0\u7b97\u6765\u62c6\u5206\u6574\u6570\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u56db\u4f4d\u6570\u7684\u6574\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7\u6574\u9664\u548c\u53d6\u4f59\u64cd\u4f5c\u6765\u83b7\u53d6\u9ad8\u4f4d\u548c\u4f4e\u4f4d\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">number = 1234\nhigh = number \/\/ 100  # \u83b7\u53d6\u9ad8\u4f4d\u90e8\u5206\nlow = number % 100    # \u83b7\u53d6\u4f4e\u4f4d\u90e8\u5206\nprint(high, low)  # \u8f93\u51fa: 12 34\n<\/code><\/pre>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u4f7f\u7528\u9012\u5f52\u65b9\u6cd5\u5c06\u6574\u6570\u62c6\u5206\u4e3a\u5404\u4e2a\u6570\u5b57\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7\u9012\u5f52\u51fd\u6570\u6765\u62c6\u5206\u6574\u6570\u3002\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u6301\u7eed\u9664\u4ee510\uff0c\u76f4\u5230\u6570\u5b57\u88ab\u5b8c\u5168\u62c6\u5206\u3002\u4ee5\u4e0b\u662f\u793a\u4f8b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">def split_number(n):\n    if n &lt; 10:\n        return [n]\n    else:\n        return split_number(n \/\/ 10) + [n % 10]\n\nnumber = 56789\nresult = split_number(number)\nprint(result)  # \u8f93\u51fa: [5, 6, 7, 8, 9]\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"Python \u5982\u4f55\u628a\u4e00\u4e2a\u6574\u6570\u62c6\u5206\u5f00\u6765 \u5728Python\u4e2d\uff0c\u628a\u4e00\u4e2a\u6574\u6570\u62c6\u5206\u6210\u5355\u4e2a\u6570\u5b57\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec [&hellip;]","protected":false},"author":3,"featured_media":1127546,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1127542"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1127542"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1127542\/revisions"}],"predecessor-version":[{"id":1127548,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1127542\/revisions\/1127548"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1127546"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1127542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1127542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1127542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}