码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
选择排序
# -*- coding: UTF-8 -*- def select_sort(a): for i in range(len(a)): min = i j = i+1 for j in range(i+1,len(a)): if a[min]>a[j]: a[min],a[j]=a[j],a[min
分类:编程语言   时间:2016-03-09 22:32:14    阅读次数:241
脚本——生成验证码的函数
#-*- coding:UTF-8 -*- # generate verification import random def generate_verification_code(lenth=6): code_list=[] for i in range(10): code_list.append
分类:其他好文   时间:2016-03-09 21:01:36    阅读次数:195
冒泡排序
# -*- coding: UTF-8 -*- def bubble_sort(a): for i in range(len(a)-1): j = 0 while(j<len(a)-i-1): if a[j]>a[j+1]: a[j],a[j+1]=a[j+1],a[j]#交换数值 j+=1 els
分类:编程语言   时间:2016-03-09 20:59:38    阅读次数:158
Python取出SQL表单中的字段名
def ReturnInfo(self, avalue, akey): cursor = connection.cursor() Sql = "select * from %s where %s=%s" % (self.table, akey, avalue) cursor.execute(Sql)
分类:数据库   时间:2016-03-09 17:40:03    阅读次数:182
python upload file
server.py #!/usr/bin/env python # -*- coding:utf-8 -*- import SocketServer import os class MySocketServer(SocketServer.BaseRequestHandler): def handle
分类:编程语言   时间:2016-03-09 12:28:58    阅读次数:127
Python标准库之os模块
1、删除和重命名文件 import os import string def replace(file, search_for, replace_with): # replace strings in a text file back = os.path.splitext(file)[0] + ".
分类:编程语言   时间:2016-03-09 11:04:11    阅读次数:230
《Dive into Python》Chapter 2 and Chapter 3 笔记
Example 2.1. odbchelper.py def buildConnectionString(params): """Build a connection string from a dictionary Returns string.""" return ";".join(["%s=%
分类:编程语言   时间:2016-03-09 11:01:13    阅读次数:195
选择排序和冒泡排序
选择排序/单元排序(Selection Sort) def selSort(L): for i in range(len(L) - 1): print L minIndx = i minVal= L[i] j = i + 1 while j < len(L): if minVal > L[j]: m
分类:编程语言   时间:2016-03-09 10:51:47    阅读次数:197
python类方法与对象方法学习
1 class Test_Demo: 2 TEST = 'test_value' 3 4 def __init__(self,name,age): 5 self.name = name 6 self.age = age 7 #static method 8 @staticmethod 9 def t
分类:编程语言   时间:2016-03-09 01:20:48    阅读次数:230
二分查找
# -*- coding: UTF-8 -*- def search(a,m): low = 0 i = 0 top = len(a) while(low<=top): mid = (low+top)/2 mids = a[mid] if m<mids:top=mid-1;i+=1;print mi
分类:其他好文   时间:2016-03-09 01:13:10    阅读次数:170
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!