随笔分类 -  90.Python

1
摘要:https://snarky.ca/how-the-heck-does-async-await-work-in-python-3-5/ 阅读全文
posted @ 2018-03-29 16:26 庚武 阅读(135) 评论(0) 推荐(0) 编辑
该文被密码保护。
posted @ 2017-12-02 23:04 庚武 阅读(3) 评论(0) 推荐(0) 编辑
摘要:import itertools 排列: 4个数内选2个 >>> print list(itertools.permutations([1,2,3,4],2)) [(1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)] 组合:4个数内选2个: >>> p... 阅读全文
posted @ 2015-06-12 12:13 庚武 阅读(1386) 评论(0) 推荐(0) 编辑
摘要:为什么归并排序如此有用?1. 快捷和稳定归并排序成为⼀一个非常棒的排序算法主要是因为它的快捷和稳定。它的复杂度即使在最差情况下都是O(n log n)。而快速排序在最差情况下的复杂度是O(n^2),当n=20的时候,它比归并要慢4.6倍。2.容易实现#coding:utf-8def merge_so... 阅读全文
posted @ 2014-05-08 15:07 庚武 阅读(1043) 评论(0) 推荐(0) 编辑
该文被密码保护。
posted @ 2014-05-03 22:00 庚武 阅读(3) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/env python# -*- coding: utf-8 -*-## functional.py# def foo(x,y,* args): sum = x + y for n in args: sum += n return sum#apply, filter, map, reducedef main(): print foo(1,2,3,4) print apply(foo,[1,2,3,4,5]) #apply是用于调用一个函数,函数本身也作为参数 #filter(func,seq),用函数判断序列中的元素是否合条件,为True,则选中,返回符合条件的li... 阅读全文
posted @ 2013-04-25 02:23 庚武 阅读(245) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/env python# -*- coding: utf-8 -*-## static_method.py# # Copyright 2013 xx <xx@ubuntu># class foo(): def __init__(self): print 'this is init' @staticmethod #声明静态方法 def bar(): print 'this is foo.bar()'def decorator1(func): def wrap1(): print 'this is wrap 1 begin&# 阅读全文
posted @ 2013-04-25 01:48 庚武 阅读(206) 评论(0) 推荐(0) 编辑
摘要:http://en.wikipedia.org/wiki/Closure_(computer_science)Incomputer science, aclosure(alsolexical closureorfunction closure) is afunctionor reference to a function together with areferencing environment—a table storing areferenceto each of thenon-local variables(also calledfree variables) of that func 阅读全文
posted @ 2012-12-05 16:18 庚武 阅读(230) 评论(0) 推荐(0) 编辑
摘要:压缩库为google提供的 Closure Compilerhttps://developers.google.com/closure/compiler/?hl=zh-cnusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Diagnostics;namespace TestProcessDosCmd{ class Program { static void Main(string[] args) { ... 阅读全文
posted @ 2012-03-16 11:52 庚武 阅读(987) 评论(0) 推荐(0) 编辑
摘要:主页:http://ironpython.net/下载地址:http://ironpython.codeplex.com/开发工具VS2010插件:http://pytools.codeplex.com/ 阅读全文
posted @ 2012-02-07 11:36 庚武 阅读(286) 评论(0) 推荐(0) 编辑
摘要:Executable Object Statements and Built-in FunctionsBuilt-in Function or Statement Descriptioncallable(obj)Returns true if obj is callable and False otherwisecompile(string, file, type)Creates a code object from string of type type; fileis where the code originates from (usually set to "")e 阅读全文
posted @ 2012-02-06 11:32 庚武 阅读(482) 评论(0) 推荐(0) 编辑
摘要:#file name: Hello.py#coding:utf-8def hello(): print 'hello中国' add = lambda x,y:x+yclass FooClass(object): """ Foo Class doc """ version = 1.0 def __init__(self,age,nm='吴xx'): self.age=age self.name=nm def show(self): print 'name:',self.name,' 阅读全文
posted @ 2012-02-05 13:46 庚武 阅读(342) 评论(0) 推荐(0) 编辑
摘要:Core Python Programming Language : Page477Anonymous Functions and lambdaPython allows one to create anonymous functions using the lambda keyword. They are "anonymous"because they are not declared in the standard manner, i.e., using the def statement. (Unless assignedto a local variable, su 阅读全文
posted @ 2012-02-04 17:17 庚武 阅读(602) 评论(0) 推荐(0) 编辑
摘要:>>> clear =lambda: os.system('cls')>>> import os>>> clear()in windows 阅读全文
posted @ 2012-02-03 11:39 庚武 阅读(334) 评论(0) 推荐(0) 编辑
摘要:ini:[COMM] C0 = 0.1C1 = 0.25C2 = 0.35C3 = 0.45C4 = 0.55C5 = 0.56[POS_TAK]PT0 = 0.1PT1 = 1.1PT2 = 2.1PT3 = 3.1PT4 = 4.1PT5 = 5.1[BET_INFO]AMT = 100.23ODDS= 48.5 py:#!/usr/bin/env python#coding=gbkimport ConfigParserimport syscomm = [] #commissionpt = [] #position takingamt = 0.0 ... 阅读全文
posted @ 2011-09-22 14:25 庚武 阅读(818) 评论(0) 推荐(0) 编辑
摘要:>>> logfile=open('/tmp/mylog.txt','a')>>> print >> logfile, 'fatail error: invalid arguments'>>> logfile.close()>>>user=raw_input("please input your name:")Numbers:int long bool (True,False)floatcomplex (6.23+1.5j)tuple1.元组, 阅读全文
posted @ 2011-08-21 15:16 庚武 阅读(231) 评论(0) 推荐(0) 编辑
摘要:在中文 windows平台下:#coding:utf-8str = "hello 我是中国人,我爱中国"print str #乱码print str.decode('utf-8').encode('gbk') 文件编码为 utf-8 阅读全文
posted @ 2011-08-21 12:00 庚武 阅读(187) 评论(0) 推荐(0) 编辑
摘要:python eclipse开发插件:http://pydev.org//download.htmldownload from sf.net: http://sourceforge.net/projects/pydev/files/pydev manual:http://pydev.org//manual_101_root.htmlother editors:http://wiki.python.org/moin/PythonEditorsURLs for PyDev as Eclipse pluginUrls to use when updating with the Eclipse upd 阅读全文
posted @ 2011-08-21 10:20 庚武 阅读(257) 评论(0) 推荐(0) 编辑
摘要:Sequence OverviewPython has six built-in types of sequences. This chapter concentrates on two of the most common ones: lists and tuples.The other built-in sequence types are strings (which I revisit in the next chapter ), Unicode strings, buffer objects, and xrange objects.Common Sequence Operations 阅读全文
posted @ 2011-01-18 18:04 庚武 阅读(229) 评论(0) 推荐(0) 编辑

1
点击右上角即可分享
微信分享提示