- 博客(15)
- 收藏
- 关注
转载 python常用数据结构
创建列表sample_list = ['a',1,('a','b')]Python 列表操作sample_list = ['a','b',0,1,3]得到列表中的某一个值value_start = sample_list[0]end_value = sample_list[-1]删除列表的第一个值del sample_list[0]在列表中插入一
2013-10-20 19:22:22
518
转载 十个python程序小技巧
十个python程序小技巧1 在作比较时你可以这样写: 3.143.14 and pi2 Int类型不会在超过31bit或32bit后溢出,它们会变成long型。在python里,long并非就是64位,他就是"长"类型,(python的长类型可以容纳数万位大的整数),效率会降低一点。在python 3000中,甚至连int与long的区别都没有了。3默认值只会在编译时
2013-10-20 19:11:31
747
转载 linux 除了某个文件或某个文件夹以外全部删除
2011-09-01 10:36 linux 除了某个文件或某个文件夹以外全部删除比如一个目录下有1,2,3,4,5这五个文件,现在我需要删除除了2以外的所有文件,那么我可以使用find . ! -name 2 -exec rm -f {} \;当然你还可以配合着 -maxdepth 来更精准的删除了.下面演示删除的范围仅限于当前目录.find . -maxdepth
2013-09-24 11:17:02
8226
原创 虚函数的缺省值
class A { virtual int vfun(int i=1024) { return i; } } class B :public A { virtual int vfun(int i=2048) { return i
2012-10-28 08:01:48
642
原创 显示目录结构的shell脚本
# !/bin/bashcurrent_path=`pwd`output_dir(){ dir=$1 #dir is a globle varible elements=`ls $dir` echo "$2""+"${dir##/*/} #get the dir name, remove the path for each in $elem
2012-10-27 18:46:54
962
转载 变量替换与扩展
原文:http://blog.csdn.net/hongkun001/article/details/6432547一、变量替换${varname:-word} 如果变量varname存在且非null,则返回其值,否则,返回word${varname-word} 如果变量varname存在,则返回其值,否则,返回word$ var=$
2012-10-27 16:50:32
323
原创 引用及虚函数
通过基类的指针可以实现动态绑定,同样,通过基类的引用,也可以实现动态绑定。#include "iostream"#include "stdlib.h"using namespace std;class emptyA{ public: emptyA(int a){v=a;} void fun(){cout<<"emptyA\n";} virtual void vf
2012-10-19 15:52:27
400
转载 shell 变量
一,SHELL本地变量: 本地变量就如同局部变量一样,只在本SHELL中起作用。它不会影响到其他SHELL中的变量。 格式:NAME=value 1,变量的调用:在变量前加$$ echo $HOME/home/hbwork$ WEEK=Satur$ echo Today is $WEEKdayToday is $echo Today
2012-09-21 21:20:16
1079
翻译 C和C++分配和释放内存的区别
c是malloc和free,c++是new和delete,区别如下:(1)new、delete 是操作符,可以重载,只能在C++中使用。(2)malloc、free是函数,可以覆盖,C、C++中都可以使用。(3)new 可以调用对象的构造函数,对应的delete调用相应的析构函数。(4)malloc仅仅分配内存,free仅仅回收内存,并不执行构造和析构函数(5)new、dele
2012-09-18 20:25:33
826
原创 用一个指针实现二维数组
文章提供三种实现方法,都通过验证 二维指针指针数组数组指针 #include #include using namespace std; const int row = 4; const int col = 5; template void gen(T **array) { for(int i=0; i<row; i++
2012-08-25 12:02:11
645
原创 read 用法
(1) 用于从terminal读入数据ngnlinux1 [** NONE **]/home/qius $ read -p "input:" input input:shang hai is a good city ngnlinux1 [** NONE **]/home/qius $ echo $input #如果只有一个参数,这个参数将保存所有的输入shang hai
2012-07-29 10:26:26
396
原创 如何获取shell脚本的可选参数
直接上例子:cat option_sh #!/bin/bashecho $*# get the optional argumentswhile getopts f:t: valuedo case $value in f ) RHOST_INFO=$OPTARG # 从$OPTARG中获得参数值 ;;
2012-07-28 16:58:10
2479
原创 Shell脚本的中的输入变量
$0 -> 完整的脚本路径和名称$1 ->第一个位置变量的字符串$2 ->第二个位置变量的字符串$* ->所有输入参数的字符串$@ -> 同上$# -> 输入参数的个数ngnlinux1 [** NONE **]/home/qius $ cat sh_test#!/bin/bashecho $0, $1,$2, $*, $@, $#shif
2012-07-28 16:27:48
1978
原创 cat命令用于输入文档到文件
(1) cat /dev/null > /etc/test.txt 把test.txt文件扔进垃圾箱(2) #! /bin/bashscriptname="cat_test"cat >> $scriptname send "${!i}\r"expect { timeout {exit 1} -re "$lastprompt"}set timeout
2012-07-28 16:00:16
1711
原创 C/C++ 核心之一 指针与数组
关于指针,谈一点自己的认识。(1) 指针本质上就是一个地址,指针所占的byte数目只跟系统位数有关,与指针所指向的类型无关。(2) p+1,指针移动的byte数目直接决定于指针所指向的数据类型(3) 定义指针时,如果指向的类型为TYPE,那么就需要定义TYPE* 类型的指针。 比较指向的类型为int*, 那么就要定义int**类型的指针(4)指向单个元素的指针和指向多个元素的指针(数组指针)
2011-04-19 21:24:00
371
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人