{"id":158541,"date":"2019-09-28T10:00:06","date_gmt":"2019-09-28T02:00:06","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=158541"},"modified":"2019-09-20T14:59:41","modified_gmt":"2019-09-20T06:59:41","slug":"python-zim-num","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/python-zim-num.html","title":{"rendered":"\u7528python\u5b9e\u73b0\u82f1\u6587\u5b57\u6bcd\u548c\u76f8\u5e94\u5e8f\u6570\u8f6c\u6362\u7684\u65b9\u6cd5"},"content":{"rendered":"
\u82f1\u6587\u5b57\u6bcd\u8f6c\u5bf9\u5e94\u6570\u5b57\u76f8\u5bf9\u7b80\u5355\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u8f93\u5165\u4e00\u884c\u9700\u8981\u8f6c\u6362\u7684\u82f1\u6587\u5b57\u6bcd\uff0c\u7136\u540e\u5bf9\u6bcf\u4e00\u4e2a\u5b57\u6bcd\u5728\u6574\u4e2a\u5b57\u6bcd\u8868\u4e2d\u5339\u914d\uff0c\u5e76\u8fd4\u56de\u76f8\u5e94\u7684\u4f4d\u6570\uff0c\u7136\u540e\u7d2f\u52a0\u8fd9\u4e9b\u4f4d\u6570\u5373\u53ef\u3002\u8fc7\u7a0b\u4e2d\uff0c\u4e3a\u4e86\u4f7f\u7ed3\u679c\u66f4\u6709\u53ef\u8bfb\u6027\uff0c\u8f93\u51fa\u76f8\u90bb\u6570\u5b57\u95f4\u600e\u52a0\u4e86\u7a7a\u683c\uff0c\u6bcf\u4e2a\u5bf9\u5e94\u539f\u6765\u5355\u8bcd\u95f4\u589e\u52a0\u9017\u53f7\u3002<\/p>\n
c=\"abcdefghijklmnopqrstuvwxyz\"\r\ntemp=''\r\nlist=[]\r\ns=input()\r\nnum=len(s)\r\nlist.append(s)\r\nfor i in range(0,num):\r\nif list[0][i]==' ':\r\ntemp+=','\r\nelse:\r\nfor r in range(1,26):\r\nif list[0][i]==c[int(r)-1]:\r\ntemp+=str(r)\r\ntemp+=' '\r\nprint(\"\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a%s\"%temp)\r\n<\/pre>\n\u7b2c\u4e8c\u6b65\uff1a\u6570\u5b57\u8f6c\u5b57\u6bcd<\/strong><\/span><\/div>\n\n
- 1.<\/strong>\u6570\u5b57\u8f6c\u5b57\u6bcd\u6709\u4e2a\u96be\u70b9\u5c31\u662f\uff0c\u5f53\u8f93\u5165\u4e00\u884c\u6570\u5b57\uff0c\u5982\u4f55\u624d\u80fd\u5408\u7406\u5730\u628a\u5b83\u4eec\u6bcf\u4e2a\u76f8\u5e94\u4f4d\u7684\u6570\u53d6\u51fa\u6765\u3002\u624d\u5f00\u59cb\u60f3\u5230\u7528\u6b63\u5219\u5339\u914d\uff0c\u5b9a\u6a21\u5f0f\u5355\u5143(\\d+,{0,}),\u7136\u540e\u5e0c\u671b\u6bcf\u4e2a\u6570\u5b57\u7528.groups()\u5f62\u5f0f\u8fd4\u56de\u4e00\u4e2a\u5143\u7ec4(tuple)\uff0c\u4f46\u9650\u4e8e\u8981\u8f93\u5165\u6570\u5b57\u7684\u4e2a\u6570\u4f4d\u7f6e\uff0c\u6ca1\u627e\u5230\u597d\u7684\u5339\u914d\u65b9\u5f0f\u3002<\/li>\n
- 2.<\/strong>\u7136\u540e\u7528\u5230\u4e86split()\u51fd\u6570\uff0c\u7528\u76f8\u5e94\u7684\u5206\u9694\u7b26\u5206\u5272\u4e00\u6bb5\u5b57\u7b26\u4e32\u4e4b\u540e\uff0c\u5c06\u503c\u5df2list\u5f62\u5f0f\u8fd4\u56de\u3002<\/li>\n<\/ul>\n
c=\"abcdefghijklmnopqrstuvwxyz\"\r\ntemp=''\r\ns=input()\r\ns_list=s.split(\",\")\r\nnum=len(s_list)\r\nfor i in range(0,num):\r\nif s_list[i]==' ':\r\ntemp+=' '\r\nelse:\r\nresult=c[int(s_list[i])-1]\r\ntemp+=result\r\nprint(\"\u8f93\u51fa\u7ed3\u679c\u662f\uff1a%s\"%temp)\r\n<\/pre>\n\u5b8c\u6574\u4ee3\u7801<\/strong><\/span><\/div>\n#-*- coding: utf-8 -*-\r\nimport re\r\ndef main():\r\nss=input(\"\u8bf7\u9009\u62e9:\\n1.\u5b57\u6bcd->\u6570\u5b57\\\r\n\\n2.\u6570\u5b57->\u5b57\u6bcd\\n\")\r\nif ss=='1':\r\nprint(\"\u8bf7\u8f93\u5165\u5b57\u6bcd: \")\r\nfun1()\r\nelif ss=='2':\r\nprint(\"\u8bf7\u8f93\u5165\u6570\u5b57\uff1a\")\r\nfun2()\r\ndef fun1():\r\nc=\"abcdefghijklmnopqrstuvwxyz\"\r\ntemp=''\r\nlist=[]\r\ns=input()\r\nnum=len(s)\r\nlist.append(s)\r\nfor i in range(0,num):\r\nif list[0][i]==' ':\r\ntemp+=','\r\nelse:\r\nfor r in range(1,26):\r\nif list[0][i]==c[int(r)-1]:\r\ntemp+=str(r)\r\ntemp+=' '\r\nprint(\"\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a%s\"%temp)\r\n\r\ndef fun2():\r\nc=\"abcdefghijklmnopqrstuvwxyz\"\r\ntemp=''\r\ns=input()\r\ns_list=s.split(\",\")\r\nnum=len(s_list)\r\nfor i in range(0,num):\r\nif s_list[i]==' ':\r\ntemp+=' '\r\nelse:\r\nresult=c[int(s_list[i])-1]\r\ntemp+=result\r\nprint(\"\u8f93\u51fa\u7ed3\u679c\u662f\uff1a%s\"%temp)\r\n\r\nif __name__ == '__main__':\r\nmain()\r\n<\/pre>\n