随笔分类 -  python

上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 48 下一页
摘要:>>> time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) '2019-01-04 11:20:25' 阅读全文
posted @ 2019-01-04 11:23 anobscureretreat 阅读(257) 评论(0) 推荐(0)
摘要:>>> import time >>> time.asctime() 'Fri Jan 4 11:17:20 2019' >>> time.asctime((2018, 9, 30, 9, 44, 31, 6, 273, 0)) 'Sun Sep 30 09:44:31 2018' >>> time.asctime(time.localtime(1538271871.226226)) 'S... 阅读全文
posted @ 2019-01-04 11:19 anobscureretreat 阅读(399) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2019-01-04 11:17 anobscureretreat 阅读(324) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2019-01-04 11:06 anobscureretreat 阅读(12736) 评论(0) 推荐(0)
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- import time localtime = time.asctime( time.localtime(time.time()) ) print("本地时间为 :", localtime) 输出: 本地时间为 : Thu Apr 7 10:05:21 2016 阅读全文
posted @ 2019-01-04 10:51 anobscureretreat 阅读(212) 评论(0) 推荐(0)
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- import time localtime = time.localtime(time.time()) print("本地时间为 :", localtime) 输出: 本地时间为 : time.struct_time(tm_year=2016, tm_mon=4, tm_mday=7, tm_hour=... 阅读全文
posted @ 2019-01-04 10:48 anobscureretreat 阅读(708) 评论(0) 推荐(0)
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- import time; # 引入time模块 ticks = time.time() print("当前时间戳为:", ticks) 输出: 当前时间戳为: 1459994552.51 阅读全文
posted @ 2019-01-04 10:42 anobscureretreat 阅读(627) 评论(0) 推荐(0)
摘要:data=[0,9,3,2,1,3,2,-2,-1] result=[x for x in data if x >=0 ] 阅读全文
posted @ 2019-01-03 19:46 anobscureretreat 阅读(194) 评论(0) 推荐(0)
摘要:def getdirsize(dirpath): size = 0 for root, dirs, files in os.walk(dirpath): size += sum([getsize(join(root, name)) for name in files]) return size 阅读全文
posted @ 2019-01-02 16:04 anobscureretreat 阅读(716) 评论(0) 推荐(0)
摘要:uu 阅读全文
posted @ 2019-01-02 11:08 anobscureretreat 阅读(644) 评论(0) 推荐(0)
摘要:如果命令执行成功并且返回,status为0,否则status不为0 output为命令执行的结果, 如上如果执行ls, output为文件或者文件夹名称的列表 阅读全文
posted @ 2018-12-31 18:17 anobscureretreat 阅读(1104) 评论(0) 推荐(0)
摘要:def make_targz(output_filename, source_dir): with tarfile.open(output_filename, "w:gz") as tar: tar.add(source_dir, arcname=os.path.basename(source_dir)) def make_targz_one_by_one(outpu... 阅读全文
posted @ 2018-12-31 17:19 anobscureretreat 阅读(2031) 评论(0) 推荐(0)
摘要:输出 或者 阅读全文
posted @ 2018-12-31 17:13 anobscureretreat 阅读(2486) 评论(0) 推荐(0)
摘要:Python中,浮点数运算,经常会碰到如下情况: 出现上面的情况,主要还是因浮点数在计算机中实际是以二进制保存的,有些数不精确。比如说: 0.1是十进制,转化为二进制后它是个无限循环的数:0.000110011001100110011001100110011001100110011001100110 阅读全文
posted @ 2018-12-31 03:53 anobscureretreat 阅读(6098) 评论(0) 推荐(0)
摘要:先说几个解决的方法,具体的有时间再细说 字典是这个,然后要对字典按照value进行排序 方法一: 方法二: 方法三: zip 之后,zip函数默认会对第一个元素进行排序的,如何取消排序? 阅读全文
posted @ 2018-12-31 03:49 anobscureretreat 阅读(167) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2018-12-31 03:39 anobscureretreat 阅读(209) 评论(0) 推荐(0)
摘要:小数位数较多,可以使用round 如: 阅读全文
posted @ 2018-12-31 02:20 anobscureretreat 阅读(2037) 评论(0) 推荐(0)
摘要:#-*- encoding=utf8 -*- import time import datetime import os '''把时间戳转化为时间: 1479264792 to 2016-11-16 10:53:12''' def TimeStampToTime(timestamp): timeStruct = time.localtime(timestamp) retur... 阅读全文
posted @ 2018-12-31 01:18 anobscureretreat 阅读(1400) 评论(0) 推荐(0)
摘要:# 用到的知识# os.path.getatime(file) 输出文件访问时间# os.path.getctime(file) 输出文件的创建时间# os.path.getmtime(file) 输出文件最近修改时间 #-*- encoding=utf8 -*-import time import 阅读全文
posted @ 2018-12-31 00:18 anobscureretreat 阅读(18384) 评论(2) 推荐(0)
摘要:先将整型转换成float型,在计算,结果就有小数了 阅读全文
posted @ 2018-12-29 13:29 anobscureretreat 阅读(1741) 评论(0) 推荐(0)

上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 48 下一页