Python函数 #函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段。
#函数能提高应用的模块性,和代码的重复利用率。 1、定义一个函数定义函数简单的规则: 1、函数代码块以def关键词开头,后接函数标识符名称和圆括号()。 2、任何传入参数和自变量必须放在圆括号中间。圆括号之间可以...
分类:
其他好文 时间:
2014-11-21 20:13:52
阅读次数:
220
#!/usr/bin/python
classVector:
def__init__(self,a,b):
self.a=a
self.b=b
def__str__(self):
return‘Vector(%d,%d)‘%(self.a,self.b)
def__add__(self,other):
returnVector(self.a+other.a,self.b+other.b)
v1=Vector(2,10)
v2=Vector(5,-2)
v3=Vector(10,10)
printv1+..
分类:
编程语言 时间:
2014-11-21 16:42:43
阅读次数:
222
0.http://www.pythonchallenge.com/pc/def/0.html很简单,求2^381 __author__ = 'lonnelan'2 3 print 2**38View Code得到答案274877906944输入地址栏:http://www.pythonchallen...
分类:
编程语言 时间:
2014-11-21 15:58:41
阅读次数:
275
ProblemPhone has letters on the number keys. for example, number 2 has ABC on it, number 3 has DEF, 4 number has GHI,... , and number 9 has WXYZ. Writ...
分类:
其他好文 时间:
2014-11-21 10:21:53
阅读次数:
195
1.lambda() 匿名函数 2.?map() def?map(function,?sequence,?*sequence_1):?#?real?signature?unknown;?restored?from?__doc__
????"""
????map(function,?sequence[,?sequence,?...])?-...
分类:
编程语言 时间:
2014-11-20 22:08:06
阅读次数:
312
今天刚刚在看一点C Shell的内容,发现一个挺好玩的东西!就是环境变量可以像数组那样来设置!具体设置语法如下:set variable=(element1 element2 ...)//注意元素之间用空格来间隔 比如我在C Shell中运行了这么一条语句 set var=(123 def h...
分类:
编程语言 时间:
2014-11-20 21:55:31
阅读次数:
197
1、空class,占空间1 class Animal(object):2 pass 2、定义__init__()空1 class Animal(object):2 def __init__():3 pass 3、declare nameclass Animal...
分类:
编程语言 时间:
2014-11-20 21:50:44
阅读次数:
304
from flask import Flask, abort, redirect, url_forapp = Flask(__name__)@app.route('/')def index(): return redirect(url_for('login'))@app.route('/log...
分类:
其他好文 时间:
2014-11-20 21:35:06
阅读次数:
165
from flask import Flask, requestfrom flask import render_templateapp = Flask(__name__)app.debug=True@app.route('/hello/')@app.route('/hello/')def hell...
分类:
其他好文 时间:
2014-11-20 21:34:55
阅读次数:
296
from flask import Flask, session, redirect, url_for, escape, requestapp = Flask(__name__)@app.route('/')def index(): #判断username是否存在session中 if ...
分类:
其他好文 时间:
2014-11-20 21:34:53
阅读次数:
245