Python基礎(二)自定義函數

一、判斷字符串,內容是否爲數字python

咱們用python;xlrd讀Excel內容時,原本只是輸入的整數字,常常讀出來的是float類型函數

咱們須要自動轉成整型,意思就是說,讀出來的和咱們輸入的同樣,可是,咱們不能直接用int轉換,緣由呢,咱們沒法肯定讀的每一個單元格的值都是數字spa

那麼咱們本身,定認一個函數以下:code

def isNumeric(value):
    try:
        tv = float(value)
        return int(tv)
    except ValueError:
        return value

 

二、獲取當前系統時間blog

import time
    #獲取當前系統時間
    def getCurTime(self):
        curTimeStr = time.strftime('%Y-%m-%d_%H-%M-%S',time.localtime()).decode('utf-8')
        return curTimeStr

 

三、utf-8

相關文章
相關標籤/搜索