python 新手常見問題

一、python 三元運算符python

無,用 if else ui

二、python 設置代碼縮進spa

全選。。而後按tabcode

三、記錄程序運行時間blog

import time

time_start=time.time()
time_end=time.time()
print('totally cost',time_end-time_start)

 四、python 字符串拼接ip

join()unicode

五、python 按行讀文本文件,並解決文件名包含中文問題rem

def readLines(fileName):
    uipath = unicode(fileName, "utf8")
    print uipath
    with open(uipath,'r') as file_object:
        contents = file_object.readlines()
        return contents

六、python 字符串分隔字符串

    []=「xxx.yyy.zzz」.split()it

七、remove 某字符

 

item=item.replace('/','')八、字符串包含index()>-1,不包含時會有異常find(),功能相同,但不包含時不會有異常
相關文章
相關標籤/搜索