码迷,mamicode.com
首页 >  
搜索关键字:print    ( 43532个结果
Linux结合sed和awk打印文件权限
问题: 过滤出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
python笔记
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实现中文垂直居中
目标: 把中文字符绘制到目标矩形的居中位置。 问题: Android的Canvas绘图,drawText里的origin是以baseline为基准的,直接以目标矩形的bottom传进drawText,字符位置会偏下。这样写代码: [java] view plain copy print? @Over ...
分类:移动开发   时间:2016-06-10 06:12:28    阅读次数:269
Python正则表达式
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
Python异常处理
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一路走来 - python基础 数据类型(一)
对于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
Python的I/O操作
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
Python函数
1.介绍 函数代码块以def关键字开头,后接函数标识符名称和圆括号; return[表达式]结束函数,不带表达式的return,默认返回None 2.函数的简单调用 def printme(str): print str return printme(11) 3.传递参数 所有参数在Python里都... ...
分类:编程语言   时间:2016-06-09 12:14:51    阅读次数:371
Python日期和时间
输出当前时间 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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!