码迷,mamicode.com
首页 >  
搜索关键字:print    ( 43532个结果
Exercise 33: While Loops
while用起来不如for安全。i = 0numbers = []while i < 6: print "At the top i is %d" % i numbers.append(i) i = i + 1 print "Numbers now: ", numbers print "At ...
分类:其他好文   时间:2014-10-25 11:48:19    阅读次数:152
Python---装饰器
装饰器是一个很著名的设计模式,经常被用于有切面需求的场景,较为经典的有插入日志、性能测试、事务处理等。装饰器是解决这类问题的绝佳设计,有了装饰器,我们就可以抽离出大量函数中与函数功能本身无关的雷同代码并继续重用。概括的讲,装饰器的作用就是为已经存在的对象添加额外的功能。 假如我要计算一个函数的执行时间: import time   def foo():     print 'in foo...
分类:编程语言   时间:2014-10-24 23:41:22    阅读次数:516
python 基础
Python 3.4 注释 ? ? # this is a comment print ? ? print(format(input, format_string)) ? ? print(‘the story be about {0}, {1} and {other}‘.format(‘apple‘, ‘monkey‘, other=‘cc‘)) ? ? print(‘t...
分类:编程语言   时间:2014-10-24 19:17:36    阅读次数:208
Exercise 31: Making Decisions
print "You enter a dark room with two doors. Do you go through door #1 or door #2?"door = raw_input("> ")if door == "1": print "There's a giant bear ....
分类:其他好文   时间:2014-10-24 18:34:08    阅读次数:242
python中property的使用
记得在cocoa中也有property的概念,python中的property与cocoa里的property好像是差不多的。下面是它的两种用法。用法一:class test(object): def __init__(self): print "init is calling"...
分类:编程语言   时间:2014-10-24 18:05:25    阅读次数:239
Exercise 30: Else And If
if __name__ == '__main__': a = 100 if a > 90: print "90" elif a > 80: print '80' elif a > 70...
分类:其他好文   时间:2014-10-24 18:04:50    阅读次数:202
Exercise 29: What If
people = 20cats = 30dogs = 15if people cats: print "Not many cats! The world is saved!"if people dogs: print "The world is dry!"dogs += 5if people...
分类:其他好文   时间:2014-10-24 18:01:42    阅读次数:159
使用shell命令分析统计日志
需要统计用户日志信息,分析出用户行为时,用shell往往能方便地取出很多数据,取出后再放置到excel中统计。 例如:统计日志中含loadCustomProcess这个地址的访问,按访问耗时排序: grep "loadCustomProcess" /home/workflow/socket.txt | awk -F " " '{print $11}'|awk -F ":" '{print $2...
分类:系统相关   时间:2014-10-24 16:43:13    阅读次数:262
Exercise 24: More Practice
print "Let's practice everything." print 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.'poem = """\tThe lovely worldwith...
分类:其他好文   时间:2014-10-24 16:18:47    阅读次数:161
decorator
def log(func): def wrapper(*args,**kw): print 'call %s():'%func.__name__ return func(*args,**kw) return wrapper @log def now(): print 'hello!' now()...
分类:其他好文   时间:2014-10-24 14:47:24    阅读次数:149
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!