欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Python中知識點(diǎn)筆記

Python中知識點(diǎn)筆記

Wentao Sun. Nov.14, 2008

 

來(lái)這個(gè)公司11個(gè)月了,最開(kāi)始來(lái)的一個(gè)筆記本用完了,里面都是工作時(shí)記錄的一些片段,看到一塊自己當時(shí)學(xué)/寫(xiě) python程序時(shí)記錄的筆記,決定放到

網(wǎng)上,供大家參考。

 

1. sys.prefix sys模塊中的perfix屬性表示的是C:\Program files\python25,即python的安裝路徑;

2. python對一個(gè)module或軟件包安裝的方法是:python setup.py install,或者可以加入--prefix=/XXX表示安裝路徑。

在一些Linux平臺或Mac OS X上,當無(wú)法開(kāi)啟root賬戶(hù)時(shí)則可以將一些python系的軟件安裝到其他地方(except for /usr/lib or /usr/include).

3. python是case sensitive的,區分大小寫(xiě);

4. SCons中 Environment的使用,我摸索了很長(cháng)時(shí)間才知道這點(diǎn)的:

   env = SCons.Script.Environment()

5. frameworkversion=... framework是OS X中的一個(gè)概念,很多軟件模塊在Mac OS X上都是以framework包為單位的;

6. 注意platform這一module;

7. python中使用unicode編程,在前面加一個(gè)'u'即可;

8. ../..表示向上跳兩層, ./表示當前目錄, ../表示上一層;

9. 用CPPDEFINES表示preprocessor definitions部分;

10. 一些用用的代碼片段(經(jīng)過(guò)長(cháng)期使用和測試的)

(1) 循環(huán)搜索目錄,包括子路徑:

# Directory Walker  is used to search all files in a sepecfied directory
class DirectoryWalker:
    
# a forward iterator that traverses a directory tree

    
def __init__(self, directory):
        self.stack 
= [directory]
        self.files 
= []
        self.index 
= 0

    
def __getitem__(self, index):
        
while 1:
            
try:
                file 
= self.files[self.index]
                self.index 
= self.index + 1
            
except IndexError:
                
# pop next directory from stack
                self.directory = self.stack.pop()
                self.files 
= os.listdir(self.directory)
                self.index 
= 0
            
else:
                
# got a filename
                fullname = os.path.join(self.directory, file)
                
if os.path.isdir(fullname) and not os.path.islink(fullname):
                    self.stack.append(fullname)
                
if os.path.isfile(fullname):
                    
return fullname

 

(2) 向一個(gè)VS工程文件中添加你想加的東西

# Add preprocessor definition to project configurations in solution file
def AddPreprocessDefinition(projectFile, defList):
    shutil.copyfile(projectFile, projectFile
+".bak")
    bakFile 
= projectFile+".bak"
    bakHandle 
= open(bakFile,'r')
    os.remove(projectFile)
    projectHandle 
= open (projectFile, 'w+')
    
for line in bakHandle.readlines( ):
        matchObj 
= re.match(r'(\s+)PreprocessorDefinitions="(.*)".*',line)
        
if matchObj:
            prefixPart 
= matchObj.group(1)
            predeflist 
= matchObj.group(2)
            
for predef in defList:
                predeflist 
= predeflist + ';' + predef
            projectHandle.write(prefixPart 
+ r'PreprocessorDefinitions="' + \
                              predeflist
+'"\n')
        
else:
            projectHandle.write(line)
    projectHandle.close()
    bakHandle.close()
    os.remove(bakFile)

 

(3) 從一個(gè)VS的solution文件中返回一串vcproj文件,或類(lèi)似的情形

# return icproject files in solution files
def ProjectsInSolution(solutionFile, projPostFix):
    projFileList 
= []
    slnFileHandler 
= open(solutionFile, 'r')
    fileContent 
= slnFileHandler.readlines()
    
for line in fileContent:
        matchObj 
= re.match(r'^Project\(\"\{.*\}\"\) = \".*\", \"(.*)\", .*',line)
        
if matchObj:
            origProjectFile 
= matchObj.groups(0)[0]
            
if os.path.splitext(origProjectFile)[1!= projPostFix:
                
continue
            icProjectFile 
= os.path.dirname(solutionFile) + \
                            
"\\" + os.path.splitext(origProjectFile)[0] + \
                            projPostFix
            
print icProjectFile
            projFileList.append(icProjectFile)
    slnFileHandler.close()
    
return projFileList

 

(4) 刪除文件

#print iccprojects
for proj in iccprojects:
    
print proj
    os.remove(proj.rstrip())
    
if os.access(proj, os.F_OK):
        os.remove(proj.rstrip())

 

11. 注意python中list的append和extend方法的不同意義。

list =  ['1', '2', '3']

list.append(['4', '5']) ==> list = ['1', '2', '3', ['4', '5']]

list.extend(['4', '5']) ==> list = ['1', '2', '3', '4', '5']

也就是說(shuō),在鏈接兩個(gè)鏈表的時(shí)候,extend是鏈接元素elements,而append則將一整個(gè)list append添加到它的后面。

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Python 炫技操作:花式導包的八種方法
python處理文本文件內容專(zhuān)題
12年年化收益14.5%的大小盤(pán)輪動(dòng),投資應該可以很簡(jiǎn)單的(代碼+數據下載)
調用jupyter notebook文件內的函數一種簡(jiǎn)單方法
python測試開(kāi)發(fā)django-157.celery異步與redis環(huán)境搭建
實(shí)戰 | 如何用 Python 自動(dòng)化監控文件夾完成服務(wù)部署!
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久