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(),功能相同,但不包含时不会有异常
相关文章
相关标签/搜索