txt中每行一个ip地址和端口号,代码可循环监控这些ip地址的指定端口是否正常 #!/usr/bin/env python # -*- coding: gbk -*- import socket,time while
python检测远程udp端口是否打开 import socket import threading import time import struct import Queue queue = Queue
python判断远程端口是否打开,下面的代码判断指定网站的80端口是否打开 import socket sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#!/usr/bin/env python 'makeFile.py -- create a file' import os ls = os.linesep # get filename while True:
#!/usr/bin/env python #! -*- coding: utf-8 -*- #图片地址样例:src="http://ww2.sinaimg.cn/large/005Yan1vjw1e
>>> import os >>> os.path.exists('d:/assist') True >>> os.path.exists('d:/assist/getTeacherList.py') True >>> os.path.isfile('d:/assist') False >>> os.path.isfile('d:/assist/getTeacherList.py') True >
利用socket包中的gethostname函数获取机器名之后,再调用gethostbyname函数获取机器的IP地址。 import socket def print_machine_info(): host_name = socket.gethostname() ip_address = socket.gethostbyname(host_name) print "Host name: %s"
exif-py是一个纯python实现的获取图片元数据的python库,官方下载地址: http://exif-py.svn.sourceforge.net/viewvc/exif-py/source/EXIF
Tkinter, PIL and data_stream tested with Python27 and Python33 by vegaseat 01mar2013 ''' import io # allows
wx.Sound(fileName, isResource=False) tested with Python27 and wxPython291 by vegaseat 25jul2013 ''' import
import ftplib ftp = ftblib.FTP("ftp.yourServer.com") ftp.login("username", "password") filename = "index.html" ftp.storlines("STOR " + filename, open(filename)) filename="app.exe" ftp.storbinary("STOR
# -*- coding: utf-8 -*- #导入三个模块 import Image,ImageDraw,ImageFont import random import math '''基本功能''' #图片宽度 width = 100 #图片高度 height = 40 #背景颜色 bgcolor = (255,255,255) #生成背景图片 image = Image.new('RGB',
#!/usr/bin/env python #coding:utf-8 import psutil import time import sys from optparse import OptionParser
exif-py是一个纯python实现的获取图片元数据的python库,官方下载地址: http://exif-py.svn.sourceforge.net/viewvc/exif-py/source/EXIF
pil功能强大,convert方法可以轻易的将图片转换,下面的代码可以将图片转换成黑白效果 from PIL import Image image_file = Image.open("convert_image.png") # open colour image image_file = image_file.convert('1') # convert image to black and w
''' @author: Administrator ''' #coding=utf-8 import os import shutil dir = "G://tmp//sz//ngtsverify" def removeDir(): for root, dirs, files in os.walk(dir, True, None, False): if 'CVS' in root: print(
python将html表格转换成CSV 使用方法:python html2csv.py *.html 这段代码使用了 HTMLParser 模块 #!/usr/bin/python # -*-
# -*- coding: utf-8 -*- import Image,ImageDraw,ImageFont import random import math, string class RandomChar(): """用于随机生成汉字""" @staticmethod def Unicode(): val = random.randint(0x4E00, 0x9FBF) return u
用python写的小程序,可以用这个程序在固定的目录之间来回的拷贝. copy one directory to another directory @author: ''' import os; import
class_config.py #!/usr/bin/env python #coding:utf-8 '''''此处定义邮件的相关参数''' class Mail_conf(): sender = 'fyxichen@126