码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
【Py】关键字
global: 在函数中修改全局变量的值 #未使用global关键字 number = 10 print(number) def fun1(): number = 5 #函数中出现的全局变量被替换为一个同名的新变量 print(number) fun1() print(number) 10 5 10 ...
分类:其他好文   时间:2016-03-31 10:40:58    阅读次数:130
A Byte of Python 笔记(5)
第7章 函数 函数是重要的程序段。它们允许你给一块语句一个名称,然后你可以在程序的任何地方使用这个名称任意多次地运行这个语句块。这被称为 调用 函数。 定义函数 函数通过 def 关键字定义。def 关键字后跟一个函数的 标识符 名称,然后跟一对圆括号。圆括号中可以包括一些变量名,该行以冒号结尾。接... ...
分类:编程语言   时间:2016-03-30 16:18:45    阅读次数:329
POJ 1930 Dead Fraction
POJ 1930 Dead Rraction 此题是一个将无限循环小数转化为分数的题目 对于一个数 x=0.abcdefdef.... 假设其不循环部分的长度为m(如abc的长度为m),循环节的长度为n(def的长度为n),此时的主要目的是消除后面的循环部分, x*10^(m+n)=abcdef.d ...
分类:其他好文   时间:2016-03-29 23:42:21    阅读次数:200
PyQt4程序图标
程序图标就是一个小图片,通常显示在程序图标的左上角(ubuntu gnome在最上侧)。 效果: (注:那个ubuntu gnome的图标就是程序图标) class Icon(QtGui.QWidget): def __init__(self, parent = None): QtGui.QWidg ...
分类:其他好文   时间:2016-03-27 21:22:30    阅读次数:248
python3 装饰器
1 def outer(fun): # f 为用out装饰的函数 2 def inner(): 3 print('装饰器!') 4 fun() 5 print('test') 6 return inner 7 8 @outer 9 def fun1(): 10 print('fun1') 11 12 ...
分类:编程语言   时间:2016-03-27 14:08:33    阅读次数:160
cumulative_distribution累积分布
def cumulative_distribution(distribution): """Return normalized cumulative distribution from discrete distribution."""#将离散分布转换成累积分布 cdf=[] #累积分布列表 cdf ...
分类:其他好文   时间:2016-03-26 21:54:41    阅读次数:232
彻底弄懂后缀数组
什么叫后缀数组 首先要知道什么叫后缀 ? 比如 字符串 abcdef 那么 abcdef bcdef cdef def ef f 就叫做后缀 也就是从最后一个字母之前的一个字母开始一直到最后一个字母(所以所 bcd不是后缀 因为没有到最后一位f) 所构成的字符串就叫做后缀 至于后缀数组能干什么?我在 ...
分类:编程语言   时间:2016-03-26 21:51:08    阅读次数:316
hdu 1542 线段树之扫描线之面积并
点击打开链接 题意:给你n个矩形,求它们的面积,重复的不重复计算 思路:用线段树的扫描线完成,将X坐标离散化后,从下到上扫描矩形,进行各种处理,看代码注释把#include #include #include #include #include using namespace std; typedef long long ll; const int maxn=1e3+10; #def...
分类:其他好文   时间:2016-03-26 08:00:46    阅读次数:176
Python关键字总结
Python中的关键字包括如下:and del from not while as elif global or with assert else if pass yield break except import print class exec in raise continue finally is return def for lambda try你想看看有哪些关键字?OK,打开一个终端,就...
分类:编程语言   时间:2016-03-26 07:40:11    阅读次数:258
python(6)-shutil模块
高级的 文件、文件夹、压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length]) 将文件内容拷贝到另一个文件中: #源码 def copyfileobj(fsrc, fdst, length=16*1024): """copy data from file-l... ...
分类:编程语言   时间:2016-03-24 16:22:17    阅读次数:282
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!