###Date: 2018.5.25

====================================================================

1、Python向上取整、向下取整和四舍五入取整函数

>>> import math
>>> math.ceil(12.5)
13.0
>>> math.floor(12.5)
12.0
>>> round(12.5)
13.0

2、获取文件大小:os.path.getsize()

'''获取文件的大小,结果保留两位小数,单位为MB'''
    def get_FileSize(filePath):
      filePath = unicode(filePath,'utf8')
      fsize = os.path.getsize(filePath)
      fsize = fsize/float(1024*1024)
      return round(fsize,2)


参考:

https://www.cnblogs.com/SZxiaochun/p/6961370.html

https://www.cnblogs.com/TTyb/p/6140867.html

https://www.cnblogs.com/shaosks/p/5614630.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
猜你喜欢
  • 2021-11-28
  • 2021-08-12
  • 2021-07-09
  • 2022-01-01
相关资源
相似解决方案