上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 33 下一页
摘要: >>> from random import randint>>> allNums = []>>> for eachNum in range(10): allNums.append(randint(1000,9999))>>> print '随机从1000-9999生成的数字中获取的10个值为:'+... 阅读全文
posted @ 2014-07-05 22:00 kissing狐 阅读(190) 评论(0) 推荐(0) 编辑
摘要: >>> def add1(a): return a + 1>>> def add2(a,b): return a + b>>> def add3(a,b,c): return a + b + c>>> a1 = [1, 2, 3, 4, 5]>>> a2 = [1, 2, 3, 4, 5]>>> a... 阅读全文
posted @ 2014-07-05 21:42 kissing狐 阅读(191) 评论(0) 推荐(0) 编辑
摘要: >>> def operat(x,y): return x*y>>> print reduce(operat,(1,2,3,4,5,6,7,8,9,10))3628800 阅读全文
posted @ 2014-07-05 21:31 kissing狐 阅读(190) 评论(0) 推荐(0) 编辑
摘要: >>> def validate(usernames): if (len(usernames) > 4) and (len(usernames) >> print filter(validate, ('admin', 'maxianglin', 'lin', 'adm', 'wanglili','... 阅读全文
posted @ 2014-07-05 21:21 kissing狐 阅读(169) 评论(0) 推荐(0) 编辑
摘要: def updatePassword(): message="" oldPwd=raw_input("Please input your old password:\n").strip() if(oldPwd != "python"): message="原始... 阅读全文
posted @ 2014-07-05 21:10 kissing狐 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Python内置函数之filter map reduce2013-06-04Posted byyehoPython内置了一些非常有趣、有用的函数,如:filter、map、reduce,都是对一个集合进行处理,filter很容易理解用于过滤,map用于映射,reduce用于归并. 是Python列表... 阅读全文
posted @ 2014-07-05 01:19 kissing狐 阅读(238) 评论(0) 推荐(0) 编辑
摘要: Python 序列化 pickle/cPickle模块2013-10-17Posted byyehoPython序列化的概念很简单。内存里面有一个数据结构,你希望将它保存下来,重用,或者发送给其他人。你会怎么做?这取决于你想要怎么保存,怎么重用,发送给谁。很多游戏允许你在退出的时候保存进度,然后你再... 阅读全文
posted @ 2014-07-05 01:16 kissing狐 阅读(372) 评论(0) 推荐(0) 编辑
摘要: 在写shell脚本时经常会用到命令行选项、参数处理方式,如:./test.sh -f config.conf -v --prefix=/home-f 为短选项,它需要一个参数,即config.conf, -v也是一个选项,但它不需要参数–prefix 是一个长选项,即选项本身多于一个字符,它也需要一... 阅读全文
posted @ 2014-07-05 01:05 kissing狐 阅读(275) 评论(0) 推荐(0) 编辑
摘要: expect自动远程拷贝脚本,利用rsync命令,脚本内容如下:#!/usr/bin/expect --proc Usage_Exit {self} { puts "" puts "Usage: $self ip user passwd port sourcefile d... 阅读全文
posted @ 2014-07-05 01:03 kissing狐 阅读(831) 评论(0) 推荐(0) 编辑
摘要: 2014年第一个脚本,哈哈!!! expect实现远程主机自动执行命令脚本:#!/usr/bin/expect --if { [llength $argv] < 4 } { puts "Usage: $argv0 ip user passwd port commands timeout" exit ... 阅读全文
posted @ 2014-07-05 01:02 kissing狐 阅读(1693) 评论(0) 推荐(0) 编辑
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 33 下一页