码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
[Python]多线程入门
Python的多线程有两种实现方法: 函数,线程类 1.函数:调用thread模块中的start_new_thread()函数来创建线程,以线程函数的形式告诉线程该做什么 2.线程类:调用threading模块,创建threading.Thread的子类来得到自定义线程类。     def f(name):     #定义线程函数     print "this is " + name...
分类:编程语言   时间:2014-06-20 12:05:41    阅读次数:287
Python读写文本文档详解
以下3步问正确的程序片段: 1.写文件 #! /usr/bin/python3 'makeTextFile.py -- create text file' import os def write_file():     "used to write a text file."          ls = os.linesep     #get filena...
分类:编程语言   时间:2014-06-20 10:47:27    阅读次数:278
leetcode--Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Def...
分类:其他好文   时间:2014-06-11 22:56:31    阅读次数:257
python实现的链表
python实现的链表,包括插入、查找、删除操作 #!/usr/bin/python class linknode(): def __init__(self,k,n=None): self.key=k; self.next=n; def createlist(): #创建链表 n=raw_input("enter the num of nodes"); n=int(...
分类:编程语言   时间:2014-06-07 12:23:46    阅读次数:204
(转)Python记录@classmethod 修饰符
通常情况下,如果我们要使用一个类的方法,那我们只能将一个类实体化成一个对象,进而调用对象使用方法。比如: class Hello(object): def __init__: ... def print_hello(self): print "Hello" 要用 ...
分类:编程语言   时间:2014-06-07 07:44:56    阅读次数:218
[算法导论]quicksort algorithm @ Python
算法导论上面快速排序的实现。代码:def partition(array, left, right): i = left-1 for j in range(left, right): if array[j] <= array[right]: i += ...
分类:编程语言   时间:2014-06-06 18:18:13    阅读次数:351
c/c++栏目中类和对象-4的python实现
# -*- coding: utf-8 -*-"""Created on Wed Jun 04 01:21:31 2014@author: Administrator"""class Analysis: def processExamResults(self): passes =...
分类:编程语言   时间:2014-06-06 13:03:57    阅读次数:354
Python,ElementTree模块处理XML时注释无法读取和保存的问题
from xml.etree import ElementTreeclass CommentedTreeBuilder ( ElementTree.XMLTreeBuilder ): def __init__ ( self, html = 0, target = None ): ...
分类:编程语言   时间:2014-06-05 13:16:31    阅读次数:261
一个截取字符串函数引发的思考
背景 前些天,遇到这样一个问题,问题的内容如下: 要求编写一个截取字符串的函数,输入为一个字符串和字节数,输出为按字节截取的字符串。但是要保证汉字不被截半个,如“我ABC”, 4,截取后的效果应该为“我AB”,输入“我ABC汉DEF”, 6,应该输出为“我ABC”,而不是“我ABC+汉的半个”。 问题 刚看到这个问题的时候,以为还是很简单的,但写出来...
分类:其他好文   时间:2014-06-01 14:47:29    阅读次数:404
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!