{"id":1304,"date":"2014-09-24T16:20:17","date_gmt":"2014-09-24T16:20:17","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=1304"},"modified":"2014-09-24T16:20:17","modified_gmt":"2014-09-24T16:20:17","slug":"%e4%b8%80%e4%ba%9bpython%e7%89%87%e6%ae%b5_4-python%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%a0%bc%e5%bc%8f%e5%8c%96","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/1304.html","title":{"rendered":"\u4e00\u4e9bPython\u7247\u6bb5_4 &amp; Python\u5b57\u7b26\u4e32\u683c\u5f0f\u5316"},"content":{"rendered":"<h6>\u7528Google API\u6293\u53d6\u641c\u7d22\u7ed3\u679c<\/h6>\n<pre class=\"lang:default decode:true\">#!\/usr\/bin\/env python\nimport urllib\nimport simplejson\nquery = urllib.urlencode({'q':'ixyzero.com'})\nurl = 'http:\/\/ajax.googleapis.com\/ajax\/services\/search\/web?v=1.0&amp;%s'%(query)\nsearch_results = urllib.urlopen(url)\njson = simplejson.loads(search_results.read())\nprint(json)\nresults = json['responseData']['results']\nprint len(results)\nfor i in results:\n    print i['title'] + \": \" + i['url']<\/pre>\n<h6>\u7528Python\u751f\u6210\u968f\u673a\u5bc6\u7801<\/h6>\n<pre class=\"lang:default decode:true \">import string, random\ndef makePassword(minlength = 5, maxlength = 25):\n    length = random.randint(minlength, maxlength)\n    letters = string.ascii_letters + string.digits\n    return ''.join([random.choice(letters) for _ in range(length)])\nprint makePassword()\n\nprint (sorted(random.sample(range(1,36), 5)) + sorted(random.sample(range(1,13),2)))<\/pre>\n<h6>\u7528Python\u751f\u6210\u968f\u673a\u5bc6\u7801_2<\/h6>\n<pre class=\"lang:default decode:true  \">import random\nclass Dictor():\n    CSet='abcdefghijklmnopqrstuvwxyz0123456789'\n    def __init__(self, minlen, maxlen):\n        if maxlen&gt;minlen:\n            self.__minlen=minlen\n            self.__maxlen=maxlen\n        else:\n            self.__minlen=maxlen\n            self.__maxlen=minlen\n    def __iter__(self):\n        return self\n    def next(self):\n        ret = ''\n        for i in range(0, random.randrange(self.__minlen, self.__maxlen+1)):\n            ret += random.choice(Dictor.CSet)\n        return ret\n\nfor word in Dictor(3, 3):\n    print str(word)<\/pre>\n<h6>\u7528Python\u751f\u6210\u4e2d\u6587\u9a8c\u8bc1\u7801<\/h6>\n<pre class=\"lang:default decode:true \">#!\/usr\/bin\/env python\n# -*- coding: utf-8 -*-\nfrom PIL import Image, ImageDraw, ImageFont\nimport random\nimport math, string\n\nclass RandomChar():\n    \"\"\"\u7528\u4e8e\u968f\u673a\u751f\u6210\u6c49\u5b57\"\"\"\n    @staticmethod\n    def Unicode():\n        val = random.randint(0x4E00, 0x9FBF)\n        return unichr(val)\n\n    @staticmethod\n    def GB2312():\n        head = random.randint(0xB0, 0xCF)\n        body = random.randint(0xA, 0xF)\n        tail = random.randint(0, 0xF)\n        val = ( head &lt;&lt; 8 ) | (body &lt;&lt; 4) | tail\n        str = \"%x\" % val\n        return str.decode('hex').decode('gb2312')\n\nclass ImageChar():\n    def __init__(self, fontColor = (0, 0, 0), size = (100, 40), fontPath = 'wqy.ttc', bgColor = (255, 255, 255), fontSize = 20):\n        self.size = size\n        self.fontPath = fontPath\n        self.bgColor = bgColor\n        self.fontSize = fontSize\n        self.fontColor = fontColor\n        self.font = ImageFont.truetype(self.fontPath, self.fontSize)\n        self.image = Image.new('RGB', size, bgColor)\n\n    def rotate(self):\n        self.image.rotate(random.randint(0, 30), expand=0)\n\n    def drawText(self, pos, txt, fill):\n        draw = ImageDraw.Draw(self.image)\n        draw.text(pos, txt, font=self.font, fill=fill)\n        del draw\n\n    def randRGB(self):\n        return (random.randint(0, 255),\n                random.randint(0, 255),\n                random.randint(0, 255))\n\n    def randPoint(self):\n        (width, height) = self.size\n        return (random.randint(0, width), random.randint(0, height))\n\n    def randLine(self, num):\n        draw = ImageDraw.Draw(self.image)\n        for i in range(0, num):\n            draw.line([self.randPoint(), self.randPoint()], self.randRGB())\n        del draw\n\n    def randChinese(self, num):\n        gap = 5\n        start = 0\n        for i in range(0, num):\n            char = RandomChar().GB2312()\n            x = start + self.fontSize * i + random.randint(0, gap) + gap * i\n            self.drawText((x, random.randint(-5, 5)), RandomChar().GB2312(), self.randRGB())\n            self.rotate()\n        self.randLine(18)\n\n    def save(self, path):\n        self.image.save(path)\n\nic = ImageChar(fontColor=(100,211, 90))\nic.randChinese(4)\nic.save(\"vcode.jpg\")<\/pre>\n<p>\u5b89\u88c5PIL\uff0c\u5e76\u4e14\u5f15\u5165\u65b9\u5f0f\u4e3a&#8221;from PIL import Image, ImageDraw, ImageFont&#8221;\uff1b\u7136\u540e\u53bb<a href=\"http:\/\/wenq.org\/wqy2\/index.cgi\" target=\"_blank\">\u5b98\u7f51<\/a>\u627e\u6587\u6cc9\u9a7f\u7684\u5b57\u4f53\uff0c<a href=\"http:\/\/jaist.dl.sourceforge.net\/project\/wqy\/wqy-zenhei\/0.8.38%20%28Pangu%29\/wqy-zenhei-0.8.38-1.tar.gz\" target=\"_blank\">\u4e0b\u8f7d<\/a>\u540e\u5b58\u4e3a&#8221;wqy.ttc&#8221;\uff0c\u4e4b\u540e\u5e94\u8be5\u5c31\u6ca1\u591a\u5927\u95ee\u9898\u4e86\u3002<\/p>\n<h6>\u731c\u6570\u5b57\u6e38\u620f<\/h6>\n<pre class=\"lang:default decode:true \">#!\/usr\/bin\/env python\n# -*- coding: utf-8 -*-\nimport random\n\n#\u6570\u5b57\u7c7b\nclass NumberItem:\n\n    #\u6570\u5b57\u4e2a\u6570\n    _GUESS_NUMBER_COUNT_ = 4\n\n    def __init__(self):\n        self._num_ = []\n\n    #\u957f\u5ea6\u662f\u5426\u6807\u51c6\n    def IsFormat(self):\n        return self._num_.__len__() == self._GUESS_NUMBER_COUNT_\n\n    #\u751f\u6210\u968f\u673a\u6570\n    def RestRandomNumber(self):\n        allNum = range(10)\n        for index in range(self._GUESS_NUMBER_COUNT_):\n            self._num_.append(allNum.pop(random.randrange(10-index)))\n\n    #\u6821\u9a8c\u8f93\u5165\u6570\n    def CheckNumber(self, input_number):\n        result = NumberCheckResult()\n\n        for index in range(self._GUESS_NUMBER_COUNT_):\n            if (input_number._num_[index] == self._num_[index]):\n                result.Add_A()\n            elif(input_number._num_[index] in self._num_):\n                result.Add_B()\n\n        return result\n\n    #\u8fd4\u56de\u5b57\u7b26\u4e32\n    def GetNumber(self):\n        return self._num_\n\n#\u7ade\u731c\u7ed3\u679c xAxB\nclass NumberCheckResult:\n    def __init__(self):\n        self._guess_A_ = 0\n        self._guess_B_ = 0\n\n    def GetCheckResult(self):\n        return '%d A %d B' % (self._guess_A_, self._guess_B_)\n\n    def Add_A(self):\n        self._guess_A_ += 1\n\n    def Add_B(self):\n        self._guess_B_ += 1\n\n#\u7ade\u731c\u5386\u53f2\u9879\nclass GuessHisItem:\n    def __init__(self):\n        self._guessNum_ = NumberItem()\n        self._guessResult_ = NumberCheckResult()\n\n    def ShowItem(self):\n        print self._guessNum_.GetNumber() , ' - ' , self._guessResult_.GetCheckResult()\n\n#\u6e38\u620f\u7c7b\nclass GuessNumberGame():\n\n    #\u673a\u4f1a\u6b21\u6570\n    _MAX_GUESS_TIMES_ = 8\n\n    def __init__(self):\n        self.ResetGameDate()\n\n    #\u91cd\u7f6e\u6e38\u620f\u6570\u636e\n    def ResetGameDate(self):\n        self._guessNum_ = NumberItem()\n        self._guessHis_ = []\n\n    def GetGuessTimes(self):\n        return self._guessHis_.__len__()\n\n    #\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u683c\u5f0f\u8f6c\u6362\n    def ChangeInputNumberFormat(self, numberStr):\n        parseNum = NumberItem()\n        if (numberStr.isdigit()):\n            for eachNum in numberStr:\n                parseNum._num_.append(int(eachNum))\n\n        return parseNum\n\n    #\u6253\u5370\u7ade\u731c\u5386\u53f2\n    def ShowGuessHis(self):\n        print ''\n        print '\u4f60\u5df2\u7ecf\u731c\u4e86 %d\u6b21, \u603b\u5171%d\u6b21\u673a\u4f1a' % (self.GetGuessTimes(), self._MAX_GUESS_TIMES_)\n        print ''\n\n        for eachItem in self._guessHis_:\n            eachItem.ShowItem()\n        print ''\n\n    def ShowHelp(self):\n        print ''\n        print '\u8f93\u5165 'help' \u663e\u793a\u547d\u4ee4\u5217\u8868.'\n        print '\u8f93\u5165 'his' \u663e\u793a\u7ade\u731c\u5386\u53f2'\n        print '\u8f93\u5165 'cheat' \u663e\u793a\u4f5c\u5f0a\u7ed3\u679c'\n        print '\u8f93\u5165 'quit' \u7ed3\u675f\u6e38\u620f'\n        print ''\n\n    def ShowCheat(self):\n        print ''\n        print '\u8981\u731c\u7684\u6570\u5b57\u662f ', self._guessNum_.GetNumber()\n        print ''\n\n    def StartOneGame(self):\n\n        self.ResetGameDate()\n\n        print '\u5f00\u59cb\u731c\u6570\u5b57\u6e38\u620f!'\n\n        self._guessNum_.RestRandomNumber()\n\n        print '\u968f\u673a\u53f7\u7801 [*' + ',*'*(self._guessNum_._GUESS_NUMBER_COUNT_-1) + ']\u5df2\u7ecf\u751f\u6210,\u4f60\u6709%d\u6b21\u673a\u4f1a!' % self._MAX_GUESS_TIMES_\n\n        #\u731c\u4e2d\u6807\u5fd7\n        guess_result = False\n        quit_flag = False\n\n        while (self.GetGuessTimes() &lt; self._MAX_GUESS_TIMES_\n               and guess_result != True and quit_flag != True):\n\n            print '\u4f60\u8fd8\u5269%d\u6b21\u673a\u4f1a,\u8f93\u5165\u4f60\u731c\u7684\u6570\u5b57:' % (self._MAX_GUESS_TIMES_- self.GetGuessTimes())\n            input_str = raw_input();\n\n            if (input_str == 'help'):\n                self.ShowHelp()\n            elif(input_str == 'his'):\n                self.ShowGuessHis()\n            elif(input_str == 'cheat'):\n                self.ShowCheat()\n            elif(input_str == 'quit'):\n                quit_flag = True\n            else:\n                #\u8f6c\u6362\u8f93\u5165\u5e76\u6821\u9a8c\n                hisItem = GuessHisItem()\n\n                hisItem._guessNum_ = self.ChangeInputNumberFormat(input_str)\n                if (hisItem._guessNum_.IsFormat() != True):\n                    print '\u6570\u5b57\u683c\u5f0f\u9519\u8bef, \u91cd\u65b0\u8f93\u5165!'\n                else:\n\n                    #\u7ade\u731c\u5386\u53f2\n                    hisItem._guessResult_ = self._guessNum_.CheckNumber(hisItem._guessNum_)\n                    self._guessHis_.append(hisItem)\n\n                    hisItem.ShowItem()\n\n                    #\u731c\u4e2d\n                    if (hisItem._guessResult_._guess_A_ == NumberItem._GUESS_NUMBER_COUNT_):\n                        guess_result = True\n                        print '\u606d\u559c,\u4f60\u731c\u4e2d\u4e86\u6570\u5b57' , self._guessNum_.GetNumber() , ' \u7528\u4e86%d\u6b21\u673a\u4f1a' % self.GetGuessTimes()\n                    elif(self.GetGuessTimes() == self._MAX_GUESS_TIMES_ ):\n                        print ''\n                        print '\u6311\u6218\u5931\u8d25,\u4f60\u5df2\u7ecf\u731c\u4e86%d\u6b21,' % self.GetGuessTimes(), '\u6b63\u786e\u7684\u6570\u5b57\u662f', self._guessNum_.GetNumber()\n\n        return quit_flag\n\n    def StartGame(self):\n        quit_flag = False\n        while(quit_flag != True):\n\n            quit_flag = self.StartOneGame()\n\n            if (quit_flag != True):\n                print ''\n                print '\u518d\u73a9\u4e00\u5c40?(Y\/N)'\n                input_str = raw_input();\n\n                if (input_str != 'Y'):\n                    quit_flag = True\n\n        print '\u518d\u89c1!'\n\n###### MAIN #######\nif __name__ == '__main__':\n    game = GuessNumberGame()\n    game.StartGame()<\/pre>\n<p>&nbsp;<\/p>\n<p>\u4ee5\u4e0a\u7684\u4ee3\u7801\u90e8\u5206\u53c2\u8003\u81ea\uff1a<a href=\"http:\/\/outofmemory.cn\/\" target=\"_blank\">http:\/\/outofmemory.cn\/<\/a><\/p>\n<hr \/>\n<h6>\u8ba1\u7b97\u9006\u6ce2\u5170\u7b97\u5f0f<\/h6>\n<pre class=\"lang:default decode:true \">#!\/usr\/bin\/env python\n#coding=utf-8\nclass Solution:\n    def add( self, num1, num2 ):\n        return num1 + num2\n\n    def sub( self, num1, num2 ):\n        return num1 - num2\n\n    def mul( self, num1, num2 ):\n        return num1 * num2\n\n    def div( self, num1, num2 ):\n        if num1 * num2 &lt; 0:\n            return -((-num1) \/ num2 )\n        return num1 \/ num2\n    operator = { \"+\": add, \"-\": sub, \"*\": mul, \"\/\": div }\n\n    def evalRPN(self, tokens):\n        nums = []\n        for s in tokens:\n          if s in [\"+\",\"-\",\"*\",\"\/\"]:\n            num2 = nums.pop()\n            num1 = nums.pop()\n            re = self.operator.get(s)(self,num1,num2)\n            nums.append(re)\n          else:\n            nums.append(int(s))\n        return nums[0]\n\ntestS = Solution()\nexpression = [\"2\", \"1\", \"+\", \"3\", \"*\"]\nprint testS.evalRPN(expression)     #((2 + 1) * 3) -&gt; 9\nexpression2 = [\"4\", \"13\", \"5\", \"\/\", \"+\"]\nprint testS.evalRPN(expression2)    #(4 + (13 \/ 5)) -&gt; 6<\/pre>\n<p><span style=\"color: #ff0000;\"><strong>\u4ee3\u7801\u6e90\u4e8e<\/strong><\/span>\uff1a<a href=\"http:\/\/huakai.paxmac.org\/?p=738\" target=\"_blank\">Evaluate Reverse Polish Notation<\/a><\/p>\n<p>&nbsp;<\/p>\n<h5>Python\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316<\/h5>\n<p>\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u4f7f\u7528\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u64cd\u4f5c\u7b26\uff0c\u5373%\u6765\u5b9e\u73b0\u3002\u5728%\u7684\u5de6\u4fa7\u653e\u7f6e\u4e00\u4e2a\u5b57\u7b26\u4e32\uff08\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\uff09\uff0c\u800c\u53f3\u4fa7\u5219\u653e\u7f6e\u5e0c\u671b\u683c\u5f0f\u5316\u7684\u503c\u3002<span style=\"color: #ff0000;\"><strong>\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u503c\uff0c\u5982\u4e00\u4e2a\u5b57\u7b26\u4e32\u6216\u8005\u6570\u5b57\uff1b\u4e5f\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a\u503c\u7684\u5143\u7ec4\u6216\u8005\u5b57\u5178\u3002<\/strong><\/span>\u4e00\u822c\u60c5\u51b5\u4e0b\u4f7f\u7528\u5143\u7ec4\uff1a<\/p>\n<pre class=\"lang:default decode:true\">&gt;&gt;&gt; format = 'Hello, %s. %s enough for ya?'\n&gt;&gt;&gt; values = ('world', 'Hot')\n&gt;&gt;&gt; print format % values\nHello, world. Hot enough for ya?<\/pre>\n<p>\u6ce8\uff1a<\/p>\n<p>\uff081\uff09\u5982\u679c\u4f7f\u7528\u5217\u8868\u6216\u8005\u5176\u4ed6\u5e8f\u5217\u4ee3\u66ff\u5143\u7ec4\uff0c\u90a3\u4e48\u5e8f\u5217\u5c31\u4f1a\u88ab\u89e3\u91ca\u6210\u4e00\u4e2a\u503c\u3002<span style=\"color: #ff0000;\"><strong>\u53ea\u6709\u5143\u7ec4\u548c\u5b57\u5178\u53ef\u4ee5\u683c\u5f0f\u5316\u4e00\u4e2a\u4ee5\u4e0a\u7684\u503c\u3002<\/strong><\/span><\/p>\n<p>\uff082\uff09<span style=\"color: #ff0000;\">\u5982\u679c\u8981\u5728\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u91cc\u9762\u5305\u62ec\u767e\u5206\u53f7\uff0c\u90a3\u4e48\u5fc5\u987b\u4f7f\u7528%%<\/span>\uff0c\u8fd9\u6837Python\u5c31\u4e0d\u4f1a\u5c06\u767e\u5206\u53f7\u8bef\u8ba4\u4e3a\u662f\u8f6c\u6362\u8bf4\u660e\u7b26\u4e86\u3002<\/p>\n<pre class=\"lang:default decode:true \">&gt;&gt;&gt; format = 'The rate is %s%, so low'\n&gt;&gt;&gt; values = 31.0\n&gt;&gt;&gt; print format % values\nTraceback (most recent call last):\n\u00a0 File \"&lt;stdin&gt;\", line 1, in &lt;module&gt; TypeError: not enough arguments for format string<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">&gt;&gt;&gt; format = 'The rate is %s%%, so low'\n&gt;&gt;&gt; values = 31.0\n&gt;&gt;&gt; print format % values\nThe rate is 31.0%, so low<\/pre>\n<p>\u5982\u679c\u8981\u683c\u5f0f\u5316\u5b9e\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528f\u8bf4\u660e\u7b26\u7c7b\u578b\uff0c\u540c\u65f6\u63d0\u4f9b\u6240\u9700\u8981\u7684\u7cbe\u5ea6\uff1a\u4e00\u4e2a\u53e5\u70b9\u518d\u52a0\u4e0a\u5e0c\u671b\u4fdd\u7559\u7684\u5c0f\u6570\u4f4d\u6570\u3002\u56e0\u4e3a\u683c\u5f0f\u5316\u8bf4\u660e\u7b26\u603b\u662f\u4ee5\u8868\u793a\u7c7b\u578b\u7684\u5b57\u7b26\u7ed3\u675f\uff0c\u6240\u4ee5\u7cbe\u5ea6\u5e94\u8be5\u653e\u5728\u7c7b\u578b\u5b57\u7b26\u7684\u524d\u9762\uff1a<\/p>\n<pre class=\"lang:default decode:true\">&gt;&gt;&gt; format = 'Pi with three decimals: %.3f'\n&gt;&gt;&gt; from math import pi\n&gt;&gt;&gt; print format % pi\nPi with three decimals: 3.142<\/pre>\n<p>\u683c\u5f0f\u5316\u64cd\u4f5c\u7b26\u7684\u53f3\u64cd\u4f5c\u6570\u53ef\u4ee5\u662f\u4efb\u4f55\u4e1c\u897f\uff0c\u5982\u679c\u662f\u5143\u7ec4\u6216\u8005\u6620\u5c04\u7c7b\u578b\uff0c\u90a3\u4e48\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u5c06\u4f1a\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<p>\u5982\u679c\u53f3\u64cd\u4f5c\u6570\u662f\u5143\u7ec4\u7684\u8bdd\uff0c\u5219\u5176\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u90fd\u4f1a\u88ab\u5355\u72ec\u683c\u5f0f\u5316\uff0c\u6bcf\u4e00\u503c\u90fd\u9700\u8981\u4e00\u4e2a\u5bf9\u5e94\u7684\u8f6c\u6362\u8bf4\u660e\u7b26\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u5982\u679c\u9700\u8981\u8f6c\u6362\u7684\u5143\u7ec4\u4f5c\u4e3a\u8f6c\u6362\u8868\u8fbe\u5f0f\u7684\u4e00\u90e8\u5206\u5b58\u5728\uff0c\u90a3\u4e48\u5fc5\u987b\u5c06\u5b83\u7528\u5706\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u4ee5\u907f\u514d\u9519\uff1a<\/p>\n<pre class=\"lang:default decode:true \">&gt;&gt;&gt; '%s plus %s equals %s' % (1, 1, 2)\n'1 plus 1 equals 2'\n\n&gt;&gt;&gt; '%s plus %s equals %s' % 1, 1, 2 # Lacks parentheses!\nTraceback (most recent call last):\n\u00a0 File \"&lt;stdin&gt;\", line 1, in &lt;module&gt; TypeError: not enough arguments for format string<\/pre>\n<table>\n<tbody>\n<tr>\n<td width=\"37\"><strong>\u683c\u5f0f<\/strong><\/td>\n<td width=\"315\"><strong>\u63cf\u8ff0<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%%<\/td>\n<td width=\"315\">\u767e\u5206\u53f7\u6807\u8bb0<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%c<\/td>\n<td width=\"315\">\u5b57\u7b26\u53ca\u5176ASCII\u7801<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%s<\/td>\n<td width=\"315\">\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%d<\/td>\n<td width=\"315\">\u6709\u7b26\u53f7\u6574\u6570(\u5341\u8fdb\u5236)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%u<\/td>\n<td width=\"315\">\u65e0\u7b26\u53f7\u6574\u6570(\u5341\u8fdb\u5236)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%o<\/td>\n<td width=\"315\">\u65e0\u7b26\u53f7\u6574\u6570(\u516b\u8fdb\u5236)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%x<\/td>\n<td width=\"315\">\u65e0\u7b26\u53f7\u6574\u6570(\u5341\u516d\u8fdb\u5236)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%X<\/td>\n<td width=\"315\">\u65e0\u7b26\u53f7\u6574\u6570(\u5341\u516d\u8fdb\u5236\u5927\u5199\u5b57\u7b26)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%e<\/td>\n<td width=\"315\">\u6d6e\u70b9\u6570\u5b57(\u79d1\u5b66\u8ba1\u6570\u6cd5)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%E<\/td>\n<td width=\"315\">\u6d6e\u70b9\u6570\u5b57(\u79d1\u5b66\u8ba1\u6570\u6cd5\uff0c\u7528E\u4ee3\u66ffe)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%f<\/td>\n<td width=\"315\">\u6d6e\u70b9\u6570\u5b57(\u7528\u5c0f\u6570\u70b9\u7b26\u53f7)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%g<\/td>\n<td width=\"315\">\u6d6e\u70b9\u6570\u5b57(\u6839\u636e\u503c\u7684\u5927\u5c0f\u91c7\u7528%e\u6216%f)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%G<\/td>\n<td width=\"315\">\u6d6e\u70b9\u6570\u5b57(\u7c7b\u4f3c\u4e8e%g)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%p<\/td>\n<td width=\"315\">\u6307\u9488(\u7528\u5341\u516d\u8fdb\u5236\u6253\u5370\u503c\u7684\u5185\u5b58\u5730\u5740)<\/td>\n<\/tr>\n<tr>\n<td width=\"37\">%n<\/td>\n<td width=\"315\">\u5b58\u50a8\u8f93\u51fa\u5b57\u7b26\u7684\u6570\u91cf\u653e\u8fdb\u53c2\u6570\u5217\u8868\u7684\u4e0b\u4e00\u4e2a\u53d8\u91cf\u4e2d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>==\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u4ee3\u7801==<\/p>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/www.cnblogs.com\/vamei\/archive\/2013\/03\/12\/2954938.html\" target=\"_blank\">http:\/\/www.cnblogs.com\/vamei\/archive\/2013\/03\/12\/2954938.html<\/a><\/li>\n<li><a href=\"http:\/\/www.w3cschool.cc\/python\/python-strings.html\" target=\"_blank\">http:\/\/www.w3cschool.cc\/python\/python-strings.html<\/a><\/li>\n<li><a href=\"http:\/\/www.yucoat.com\/python\/python_format.html\" target=\"_blank\">http:\/\/www.yucoat.com\/python\/python_format.html<\/a><\/li>\n<li><a href=\"http:\/\/www.cnblogs.com\/mingaixin\/archive\/2012\/10\/12\/2720914.html\" target=\"_blank\">http:\/\/www.cnblogs.com\/mingaixin\/archive\/2012\/10\/12\/2720914.html<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u7528Google API\u6293\u53d6\u641c\u7d22\u7ed3\u679c #!\/usr\/bin\/env python import urllib i [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,12],"tags":[8,347,348,349],"class_list":["post-1304","post","type-post","status-publish","format-standard","hentry","category-programing","category-tools","tag-python","tag-random","tag-348","tag-349"],"views":2384,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=1304"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1304\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=1304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=1304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=1304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}