![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
Gerry_Yang11
这个作者很懒,什么都没留下…
展开
-
Python os.path模块的使用
os.path.isabs(path) #判断是否为绝对路径os.path.isfile(path) #判断路径是否为文件os.path.isdir(path) #判断路径是否为目录os.path.islink(path) #判断路径是否为链接os.path.ismount(path) #判断路径是否为挂载点()os.path.join(path1[, path2[, ...]]) #...原创 2018-03-13 14:55:03 · 330 阅读 · 0 评论 -
python 获取本地计算机名
import sockethostname = socket.gethostname()print "Host Name:%s" %hostname原创 2018-03-13 15:10:15 · 1852 阅读 · 0 评论 -
python 读取文本文件的行号及行内容
Python 读取文件时同时输出行号与行内容。file = open("file.txt","r")for num,value in enumerate(file): print "the nume:%s,the value is %s" %(num,value)file.close()如果想打印从行号1开始就把enumerate(file)改为enumerate(file,1)...原创 2018-03-24 09:39:53 · 25463 阅读 · 1 评论 -
python 按照固定顺序迭代python字典
python字典对(key,value)的存储是无序的,因此直接迭代输出字典(key,value)对是无规律的。比如下面例子: from collections import defaultdict, OrderedDict grade = defaultdict() grade['小明'] = 90 grade['小王'] = 80 grade['小张'] = 70...原创 2018-03-27 16:56:27 · 6902 阅读 · 1 评论