问题: 过滤出stat /etc/hosts的权限值 法1: [root@lanny ~]# stat /etc/hosts|sed -n '4p'|awk -F '[0/]' '{print $2}' 644 注: Awk里的[0/]表示 Access: (0644/-rw-r--r--) 法2: ...
分类:
系统相关 时间:
2016-06-10 08:30:05
阅读次数:
328
def Function(args): print args print apply(Function,'aaa') #apply 是用来执行函数的 #!coding:utf-8 assert(1==1)#取值相等则往下走 print 'aaa' def foo(*arg): for item in ...
分类:
编程语言 时间:
2016-06-10 06:16:38
阅读次数:
262
目标: 把中文字符绘制到目标矩形的居中位置。 问题: Android的Canvas绘图,drawText里的origin是以baseline为基准的,直接以目标矩形的bottom传进drawText,字符位置会偏下。这样写代码: [java] view plain copy print? @Over ...
分类:
移动开发 时间:
2016-06-10 06:12:28
阅读次数:
269
1.re.match函数 import re print re.match("www","www.baidu.com").span()#(0,3) 2.group import re line = "Cats are smarter than dogs" matchObj = re.match(r'... ...
分类:
编程语言 时间:
2016-06-09 22:11:45
阅读次数:
193
这个程序的核心内容就是def语句,if语句和while语句循环的重复使用。 参考: 习题—35 # coding: utf-8def dead(why): # 定义dead函数,exit()可用于退出循环 print why, 'YOU DEAD!' # exit(0) 表示正常退出,exit(1) ...
分类:
其他好文 时间:
2016-06-09 22:09:23
阅读次数:
183
1.try…except…else try: fn = open("aa.txt","r") fn.write("这是一个测试文件") except Exception as e: print "错误提示",e.message else: print "写入内容成功" fn.close() 2.tr... ...
分类:
编程语言 时间:
2016-06-09 16:01:02
阅读次数:
183
对于Python,一切事物都是对象,对象基于类创建 入门知识拾遗 一、作用域 对于变量的作用域,执行声明并在内存中存在,该变量就可以在下面的代码中使用。 1 2 3 if 1==1: name = 'wupeiqi' print name 1 2 3 if 1==1: name = 'wupeiqi ...
分类:
编程语言 时间:
2016-06-09 15:55:42
阅读次数:
137
1.读取键盘输入 msg = raw_input("Please enter :") print "you input ",msg #可接受Python表达式作为输入 msg2 = input("请输入:") print "你输入了",msg2 2.读文件 fo = open("foo.txt","... ...
分类:
编程语言 时间:
2016-06-09 15:52:54
阅读次数:
134
1.介绍 函数代码块以def关键字开头,后接函数标识符名称和圆括号; return[表达式]结束函数,不带表达式的return,默认返回None 2.函数的简单调用 def printme(str): print str return printme(11) 3.传递参数 所有参数在Python里都... ...
分类:
编程语言 时间:
2016-06-09 12:14:51
阅读次数:
371
输出当前时间 import time#引入time模块 print time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()) 输出日历 import calendar; cal = calendar.month(2016,1); print cal; ...
分类:
编程语言 时间:
2016-06-09 10:58:57
阅读次数:
166