偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

解析初學(xué)Python時(shí)注意事項(xiàng)

開(kāi)發(fā) 后端
那天用Python寫(xiě)代碼感覺(jué)非常意外,今天用了一天的時(shí)間進(jìn)行學(xué)習(xí)和研究,當(dāng)然也是為我們的那個(gè)程序服務(wù),下面進(jìn)行講解初學(xué)Python的感受。

初學(xué)Python時(shí)需要注意相關(guān)事項(xiàng),首先初學(xué)Python時(shí)要先知道什么是Python?那么下面說(shuō)一下什么是Python,所謂Python:是一種面向?qū)ο蟆⒅弊g式計(jì)算機(jī)程序設(shè)計(jì)語(yǔ)言,也是一種功能強(qiáng)大而完善的通用型語(yǔ)言。

我們目前要把一個(gè)表態(tài)HTML頁(yè)面轉(zhuǎn)換成PORTAL。由于表態(tài)頁(yè)面數(shù)量很大,所以我們采用動(dòng)態(tài)改寫(xiě)的方法。由于這篇的目的不是介紹我們的項(xiàng)目。所以直接說(shuō)我的腳本。由于我們的工作,我們現(xiàn)在做操作前要對(duì)所以的靜態(tài)頁(yè)面進(jìn)行簡(jiǎn)單的標(biāo)記分析。這里主要分析TABLE,TR和TD。

下面貼下我的代碼:初學(xué)Python主要是兩個(gè)文件:

  1. import os, fnmatch  
  2.  
  3. # judge comment tag to delete comment statement  
  4. def judgeComment (line):  
  5.     openTag = line.find('<!--')  
  6.     closeTag = line.find('-->')  
  7.     if openTag != -1:  
  8.         if closeTag != -1:# <!--  --> 
  9.             return 1  
  10.         else:#<!--  
  11.             return 2  
  12.     elif closeTag != -1:#--> 
  13.         return 3  
  14.     else:#  
  15.         return 4  
  16.  
  17. # sort for a 2 dimension list(array)  
  18. def sortFor2di (listtosort):  
  19.     size = len(listtosort)  
  20.     for i in range(size-1):  
  21.         for j in range(i + 1,size):  
  22.             list1 = listtosort[i]  
  23.             list2 = listtosort[j]  
  24.             if list1[0] > list2[0]:  
  25.                 listtosort[i],listtosort[j] = listtosort[j],listtosort[i]  
  26.  
  27. # get all tags in a line in the form of list  
  28. def getLineTagList (line):  
  29.     taglist = []  
  30.     addTag2List (line,'table',taglist)  
  31.     addTag2List (line,'tr',taglist)  
  32.     addTag2List (line,'td',taglist)  
  33.     sortFor2di (taglist)  
  34.     return taglist  
  35.  
  36. def addTag2List (line,tag,taglist):  
  37.     pos = line.find('<'+tag)  
  38.     if pos != -1:  
  39.         taglist.append([pos,'<'+ tag + '>'])  
  40.     pos = line.find('</'+tag+'>')  
  41.     if pos != -1:  
  42.         taglist.append([pos,'</' + tag + '>'])  
  43.  
  44. def addDelTag(itemlist,stackList):  
  45.     tag = itemlist[1]  
  46.     res = 0 
  47.     res += judgeWhichTag (tag,'table',stackList)  
  48.     res += judgeWhichTag (tag,'tr',stackList)  
  49.     res += judgeWhichTag (tag,'td',stackList)  
  50.     if res != 0:  
  51.         return -1  
  52.     else:  
  53.         return 1  
  54.  
  55. #       
  56. def judgeWhichTag (tag,lable,stackList):  
  57.     if tag == '<' + lable + '>':  
  58.         stackList.append(lable)  
  59.         return 0  
  60.     elif tag == '</' + lable + '>':  
  61.         size = len(stackList)  
  62.         if size < 1: 
  63.             return -1  
  64.         elif stackList[size - 1] == lable:  
  65.             del(stackList[size -1 ])  
  66.             return 0  
  67.         else:  
  68.             return -1  
  69.     else:  
  70.         return 0  
  71.  
  72. # used to deal tag         
  73. def tagDeal (tag, line,stackList):  
  74.     openTag = line.find('<'+tag)  
  75.     closeTag = line.find('</'+tag+'>')  
  76.     if openTag != -1:  
  77.         stackList.append (tag)  
  78.         if closeTag == -1:  
  79.             return 1  
  80.     if closeTag != -1:  
  81.         size = len(stackList)  
  82.         if size < 1: 
  83.             return -1  
  84.         else:  
  85.             lastItem = stackList[size - 1]  
  86.             if lastItem != tag:  
  87.                 return -1  
  88.             else:  
  89.                 del (stackList[size - 1])  
  90.                 return 1  
  91.  
  92. def find (pattern,startdir=os.curdir):  
  93.     files = []  
  94.     os.path.walk(startdir,visitor,(pattern,files))  
  95.     files.sort()  
  96.     return files  
  97.  
  98. def visitor ((pattern,files),thisdir,names):  
  99.     for name in names:  
  100.         if fnmatch.fnmatch(name,pattern):  
  101.             fullpath = os.path.join(thisdir,name)  
  102.             files.append(fullpath) 

申明一下,我是初學(xué)Python。上面的程序?qū)懙煤軄y,以后有時(shí)間再修改或加點(diǎn)注釋。當(dāng)然很歡迎各位朋友給點(diǎn)意見(jiàn)。不過(guò),***的結(jié)果是我們的總共1000表態(tài)頁(yè)面中共有200個(gè)頁(yè)面這三種標(biāo)簽有錯(cuò)誤。這就意味著有一大堆事情要處理。至于怎么做我們還沒(méi)做好決定。

【編輯推薦】

  1. 如何使Python嵌入C++應(yīng)用程序?
  2. 深入探討Ruby與Python語(yǔ)法比較
  3. Python學(xué)習(xí)資料介紹分享
  4. Python學(xué)習(xí)經(jīng)驗(yàn)談:版本、IDE選擇及編碼解決方案
  5. 淺析Python的GIL和線程安全
責(zé)任編輯:chenqingxiang 來(lái)源: 51CTO.com
相關(guān)推薦

2010-01-26 16:54:58

學(xué)習(xí)C++

2009-09-01 17:25:33

初學(xué)C#編程

2009-12-08 09:45:50

調(diào)用WCF

2009-10-21 17:32:30

綜合布線注意事項(xiàng)

2011-05-03 16:58:55

噴墨打印機(jī)墨水

2010-03-16 10:16:18

2010-01-14 18:19:40

C++語(yǔ)言

2010-09-16 09:52:49

CSS display

2010-01-25 18:12:28

C++

2010-01-26 16:47:47

VC++6.0

2011-08-02 13:08:06

Oracle索引

2010-01-27 09:12:01

C++語(yǔ)言學(xué)習(xí)

2022-06-22 10:19:20

員工談判專(zhuān)家

2011-07-01 14:33:19

網(wǎng)站優(yōu)化

2012-06-13 02:02:43

ServletJavaJSP

2011-06-29 09:56:29

QT UI 動(dòng)態(tài)加載

2010-02-03 14:49:54

Python 模塊

2010-02-01 17:01:16

初學(xué)Python

2009-12-15 17:47:17

VSIP

2010-08-10 08:49:32

FlexSDK4
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)