内置函数 一, 文档说明 原始文档来自于python v2.7.2 中文译文和用法尚不完全,您可以自由修改和完善, 您可以在文档结尾鸣谢添上您的名字,我们将会感谢您做的 贡献! 二,函数列表 1,取绝对值
PYTHON官方手册学习笔记 一:PYTHON安装配置 1、windows安装Python之后需要配置环境变量 在dos窗口运行 set path = %path%;d:\python32即可、设置
Despite Python's increasing popularity on Windows, Python Programming on Win32 is the first book to demonstrate how to use it as a serious Windows development and administration tool. This book addresses all the basic technologies for common integration tasks on Windows, explaining both the Windows issues and the Python code you need to glue things together.
pychecker是一个在Python源代码中查找bug的工具. 对于C和C++这样的不那么动态的(译者注: 原文是less dynamic)语言, 这些bug通常由编译器来捕获. pychecker和lint类似. 由于Python的动态特性, 有些警告可能不对. 不过伪告警应该很少.
import string,random def makePassword(minlength=5,maxlength=25): length=random.randint(minlength,maxlength) letters=string.ascii_letters+string.digits # alphanumeric, upper and lowercase return ''.joi
= 'administrator' # encoding: utf-8 #!/usr/bin/python import smtplib from email.mime.text import MIMEText
python算法 - python实现冒泡排序 冒泡排序的运算原理: 比较相邻的元素。如果第一个比第二个大,就交换他们两个。 对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对。在这一点,最后的元素应该会是最大的数。
通过正规表达式实现 ''' a regex-based JavaScript code compression kludge ''' import re class JSCompressor(object): def __init__(self, compressionLevel=2, measureCompression=False): ''' compressionLevel: 0 - no
注意:下载的cx_Oracle版本要与自己的python环境版本一致,否则可能连接数据库时报错。 3、python代码 # -*- mode: python; coding: utf-8 -*- # # python operate
#!/usr/bin/python #_*_coding:utf-8_*_ # ''' 名称:快速多线程ping程序 ''' import pexpect import datetime from threading
# -*- coding: utf-8 -*- import os,sys,urllib,re import win32api import subprocess import time print "AirSSH 线路连接器(出现using username<用户名>表示连接成功:" username=raw_input("输入Air SSH用户名:") password=raw_input("
#!/usr/bin/python # vim:set fileencoding=utf-8 # 在春节放假前两天我偶然看到了A*算法,感觉挺有意思。正好放假前 # 也没有什么事情,就花了一个下午写出算法的骨架,节后又花了半天
# -*- coding: cp936 -*- import urllib2 import urllib def postHttp(name=None,tel=None,address=None, price=None,num=None,paytype=None, posttype=None,other=None): url="http://www.xxx.com/dog.php" #定义要提交的
import Image, ImageEnhance def reduce_opacity(im, opacity): """Returns an image with reduced opacity.""" assert opacity >= 0 and opacity <= 1 if im.mode != 'RGBA': im = im.convert('RGBA') else: im = i
Python 写windows 服务,需要使用 pywin32包。 直接上代码: #encoding=utf8 ''' Created on 2014-7-1 @author: wangmengnan
在自动化脚本中,文件下载是比较常见的操作,一般情况下,我们会将文件放到某个http服务器上,这时,当脚本中需要这个文件时,就需要使用到http下载的功能了 最基本的下载功能实现 实现最基本的功能,传入文件下载路径和文件本地保存路径,下载到本地 def DownloadFile(url,savePath): """ | ##@函数目的: 下载文件 | ##@参数说明:url:文件的url路径 | #
#!/usr/bin/env python import sys def search2(a,m): low = 0 high = len(a) - 1 while(low <= high): mid
def shellSort(items): inc = len(items) / 2 while inc: for i in xrange(len(items)): j = i temp = items[i] while j >= inc and items[j-inc] > temp: items[j] = items[j - inc] j -= inc items[j] = temp inc
python的包很丰富, difflib是用来做文本比较的,下面是一个使用例子: import difflib lines1 = ''' dog cat bird buffalo gophers hound
# Import python libs import os def is_writeable(path, check_parent=False): ''' Check if a given path