摘要: Python的platform模块 原创 2015年03月01日 22:20:29 标签:python /platform 3866 python中,platform模块给我们提供了很多方法去获取操作系统的信息 如: import platform platform.platform() #获取操作系统名称及版本号,'Linux-3.... 阅读全文
posted @ 2017-12-28 12:00 雷神约 阅读(284) 评论(0) 推荐(0) 编辑
摘要: python之模块之shutil模块 shutil -- --High-level file operations 高级的文件操作模块。 os模块提供了对目录或者文件的新建/删除/查看文件属性,还提供了对文件以及目录的路径操作。比如说:绝对路径,父目录…… 但是,os文件的操作还应该包含移动 复制 打包 压缩 解压等操作,这些os模块都没有提供。 而本章所讲的shutil... 阅读全文
posted @ 2017-12-21 10:49 雷神约 阅读(299) 评论(0) 推荐(0) 编辑
摘要: os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录;相当于shell下cd os.curdir 返回当前目录: ('.') os.pardir 获取当前目录的父目录字符串名:('..') os.makedirs('dirname1/dirname2') 可生成多层递归目录 os.removedi... 阅读全文
posted @ 2017-12-20 11:01 雷神约 阅读(162) 评论(0) 推荐(0) 编辑
摘要: os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录;相当于shell下cd os.curdir 返回当前目录: ('.') os.pardir 获取当前目录的父目录字符串名:('..') os.makedirs 阅读全文
posted @ 2017-12-20 11:00 雷神约 阅读(130) 评论(0) 推荐(0) 编辑
摘要: ython的os.stat中主要的时间信息有三个:st_mtime,st_atime,st_ctime。 1、st_mtime:time of last modification 最后一次修改时间,如果使用write函数写某个文件,会改变文件的这个时间 2、st_atime:time of last 阅读全文
posted @ 2017-12-20 09:35 雷神约 阅读(3003) 评论(0) 推荐(0) 编辑
摘要: import re ''' 函数: findall() #会将所有的匹配的内容输出 search() #返回一个正则的对象 split() #侵害内容 match() #也是将一个符合内容的值给取出来 compile #先将正则表达式给编译出来,然后再用这个编译后的表达式来直接匹配内容 sub() #将匹配出来的内容给替换成一个相关的内容... 阅读全文
posted @ 2017-03-14 20:35 雷神约 阅读(327) 评论(0) 推荐(0) 编辑
摘要: # \r 默认表示将输出的内容返回到第一个指针,这样的话,后面的内容会覆盖前面的内容 def main(): for i in range(65,91): s="\r{name:s}".format(name=chr(i)) time.sleep(0.5) sys.stdout.write(s) main() # r 的用法 s="... 阅读全文
posted @ 2017-03-13 17:50 雷神约 阅读(15314) 评论(0) 推荐(1) 编辑
摘要: from test import test ''' __mame__ __file__ __cache__ __package__ ''' # import os # 获取这个当前文件的绝对路径 # print(os.path.abspath(__file__)) # abspath=os.path.abspath(__file__) #获取这个文件的名字 # print(os.pa... 阅读全文
posted @ 2017-03-13 16:12 雷神约 阅读(834) 评论(0) 推荐(0) 编辑
摘要: # import time # 返回时间戳 # print(time.time()) #返回时间戳 # print(time.gmtime()) #返回utc时间戳 # print(time.localtime(tim... 阅读全文
posted @ 2017-03-12 10:16 雷神约 阅读(1859) 评论(0) 推荐(0) 编辑
摘要: 1 import time 2 3 # 返回时间戳 4 t=time.time() 5 print(t) name="one"''' bin() oct() hex() bytes() ascii() any() all() abs() bool() str() dict() list() callable() 判断能不能被调用,多数用于函数 char() 将ascii码对应的数... 阅读全文
posted @ 2017-03-09 18:14 雷神约 阅读(156) 评论(0) 推荐(0) 编辑