码迷,mamicode.com
首页 >  
搜索关键字:print    ( 43532个结果
Mac 學習系列之Python Challenge 1-10
give you two var a and b, print the value of a+b, just do it!! Answer: print a+b 给你一个list L, 如 L=[2,8,3,50], 对L进行升序排序并输出, 如样例L的结果为[2,3,8,50] Answer: L=[2,8,3,50] L.sort() or L.sorted() print L...
分类:编程语言   时间:2015-08-16 23:14:12    阅读次数:170
理解函数指针
1.直接调用函数void fun(int x); //此处的声明也可写成:void fun( int );int main(int argc, char* argv[]){ fun(10); //调用函数 return 0;}/*定义*/void fun(int x){ print...
分类:其他好文   时间:2015-08-16 21:08:08    阅读次数:92
Python 之 读取txt文件
本文直接给出三种实现方法,代码如下。 方法一: f = open("Proc_Data.txt") # 返回一个文件对象 line = f.readline() # 调用文件的 readline()方法 while line: print line, # 后面跟 ',' 将忽略换行符...
分类:编程语言   时间:2015-08-16 15:15:09    阅读次数:120
leetcode 的shell部分4道题整理
对shell的某些细节还不是十分熟悉,借鉴了好多别人的东西1. Word Frequency 此题很简单,只要能排序就可以 cat words.txt |tr -s " " "\n" sort | unique -c | sort -r | awk '{print $2" "$1}'2.Val...
分类:系统相关   时间:2015-08-16 15:10:39    阅读次数:164
Python3.4 Python的一些特色
1.使用列表综合>>> listone = [2, 3, 4] >>> listtwo = [2*i for i in listone if i > 2] >>> print(listtwo) [6, 8] 这里我们为满足条件(if i > 2)的数指定了一个操作(2*i),从而导出一个新的列表。注意原 来的列表并没有发生变化。在很多时候,我们都是使用循环来处理列表中的每一个元素,而使 用列表综...
分类:编程语言   时间:2015-08-16 12:28:14    阅读次数:149
【python】查找字符串时哪一种写法出结果速度更快?
现有一文本,每行一条数据,实现这行数据中有所要关键字则打出这行 import sys with open(sys.argv[1]) as alls: alls2 = [_.strip() for _ in alls] for _ in alls2: if sys.argv[2] in _: print _ 一开始我是这么写的,后来觉得既不美观,速度又慢(运行花了2.31 s),进...
分类:编程语言   时间:2015-08-16 10:48:30    阅读次数:129
shell-like program(shell程序的基本实施部分)
直接上代码: #include "apue.h" #include int main(void) { char buf[MAXLINE]; /* form apue.h 4096 */ pid_t pid; int status; printf("%% "); /* print promt (printf requires %% to p...
分类:系统相关   时间:2015-08-16 10:48:08    阅读次数:271
python中打印文件名,行号,路径
print "I have a proble! And here is at Line: %s"%sys._getframe().f_linenoPDB,哈哈http://docs.python.org/library/pdb.htmlimport fileinputfileinput.filen....
分类:编程语言   时间:2015-08-16 07:04:32    阅读次数:181
Python入门(九) 函数-闭包
在Python中,函数也是一种变量类型,也就是说可以用变量去保存一个函数。 def?hello(): ????print("hello") print(type(hello)) >>>?<class?‘function‘> #将函数对象赋值为变量func,此时func指...
分类:编程语言   时间:2015-08-16 00:53:22    阅读次数:151
正宗冒泡法-java语言实现
冒泡法的思想就是:小的不停地“向前跑”,大的不停地“向后”冒。 代码如下: public class Main { public static void main(String[] args) { int a[]={7,8,1,3,5}; System.out.println("排序前:"); print(a); ...
分类:编程语言   时间:2015-08-16 00:46:13    阅读次数:118
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!