1、判断字符串,内容是否为数字

我们用python;xlrd读Excel内容时,本来只是输入的整数字,经常读出来的是float类型

我们需要自动转成整型,意思就是说,读出来的和我们输入的一样,但是,我们不能直接用int转换,原因呢,我们无法确定读的每个单元格的值都是数字

那么我们自己,定认一个函数如下:

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

 

2、获取当前系统时间

import time
    #获取当前系统时间
    def getCurTime(self):
        curTimeStr = time.strftime('%Y-%m-%d_%H-%M-%S',time.localtime()).decode('utf-8')
        return curTimeStr

 

3、

 

相关文章:

  • 2022-01-20
  • 2021-05-19
  • 2021-10-29
  • 2021-10-29
  • 2021-10-19
  • 2021-05-17
  • 2022-12-23
  • 2021-10-12
猜你喜欢
  • 2021-10-19
  • 2021-10-19
  • 2021-10-19
  • 2021-11-19
  • 2022-12-23
  • 2021-12-21
  • 2021-10-19
相关资源
相似解决方案