python获取本地IP,并写入文件
2013-03-18 17:49
323 查看
#获取IP
import socket
localIP = socket.gethostbyname(socket.gethostname())
print "local ip:%s "%localIP
#写入文件
fileHandle = open ('d:/test.txt', 'w')
fileHandle.write (localIP)
fileHandle.close()
#读取文件
fileHandle = open ('d:/test.txt','r')
fileList = fileHandle.readlines()
for fileLine in fileList:
print '>>', fileLine
fileHandle.close()
import socket
localIP = socket.gethostbyname(socket.gethostname())
print "local ip:%s "%localIP
#写入文件
fileHandle = open ('d:/test.txt', 'w')
fileHandle.write (localIP)
fileHandle.close()
#读取文件
fileHandle = open ('d:/test.txt','r')
fileList = fileHandle.readlines()
for fileLine in fileList:
print '>>', fileLine
fileHandle.close()
相关文章推荐
- python3 linux 下获取本地网卡ip
- Python urllib模块urlopen()【打开网站,写入本地文件】与urlretrieve()【直接下载网站文件到本地】
- python获取接口数据,写入文件
- python 获取文件名称和读取写入文件小结
- python获取系统基础性能参数实现写入文件
- python从页面获取中文,写入指定文件中
- java中如何获取远程计算机post提交的数据并把这些数据写入本地的txt文件中
- Python 获取本地IP
- python+adb获取当前activity的名字,并写入到文件中
- python3将本地JSON数据文件(大文件)写入MySQL数据库
- python 获取本地ip
- python利用标准库如何获取本地IP示例详解
- python之获取本地文件名称
- Python 2.7_Second_try_爬取阳光电影网_获取电影下载地址并写入文件 20161207
- python之获取目录下的文件名并写入文件
- Python3.4 获取百度网页源码并保存在本地文件中
- jmeter 调用接口获取随机身份证,beanshell 写入到本地文件
- NSIS获取本机IP地址写入配置文件
- python 获取指定文件夹下所有文件名称并写入列表的实例
- python开发_搜索本地文件信息写入文件