c++ const和指针* 左定值,右定向。左定值:当const在的左侧时,指针所指向的值保持不变(或者说,不能通过指针来修改其所指向的值)。右定向:当const在的右侧时,指针所指的方向保持不链。例子 1-1#include <iostream>using namespace std;int main(){ const char* str1; str1 = "mystr1"; ...
快速生成wget使用的ftp地址 目录简述实现使用简述快速生成ftp地址供wget使用。从同事那学到的快速有效的tip。实现修改~/.bashrc,添加如下函数function loc(){ myname=`hostname` for arg in "$@" do mypath=`readlink -f $arg` echo "ftp://"$myname""$...
c++笔记 字符串/string比较 string对象的比较1.直接使用==,相等返回1,不相等返回0;2.使用string对象的compare方法,相等返回0,str1>str2返回1,str1<str返回-1;例子:#include "string.h"#include "iostream.h"using namespace std;int main(){ string str1 = "aaa"...
linux/mac tar包解压压缩命令 仅对最常用的tar包的解压压缩命令进行记录注意,打包/解包 和 压缩 是两回事,前者是-c和-x控制,后者是-z决定。参数:-c 压缩-x 解压缩-v 解压压缩过程中显示档案,可视化(visualize)-z 使用gzip压缩-f 后面立即接文件名-C 解压缩时,解压至指定路径例子:将output路径打包成tar包tar cvf output.tar /home/work/o...
hadoop streaming 常用参数 以及 动态调整 常用参数多路输出:hadoop streaming 支持多路输出,每个reducer可以将数据输出到part-xxxxx-[A-Z]为了多路输出,需要:1.设定hadoop参数:-outputformat org.apache.hadoop.mapred.lib.SuffixMultipleSequenceFileOutputFormat2.输出的数据需要在最后加上#[A-Z]比如...
shell利用awk从文件中随机选取n行 工作中经常需要在文件中随机抽取几行的数据来分析,但是公司的虚拟机不支持连外网,同时没有shuf工具。但是默认是有awk工具的。创建一个shell脚本,内容如下:#!/bin/bashIN_FILE=$1LINE_NUM=$2awk -vN=${LINE_NUM} -vC="`wc -l ${IN_FILE}`" 'BEGIN{srand();while(n<N){i=int(r...
shell脚本中使用sed替换路径字符串 示例场景如下:shell中获取某一bin的路径(如ctags),并将其写入到某一配置文件(如.vimrc)中。首先ctags_bin=`which ctags`获取bin的路径,然后插入到配置文件的某一行sed -i '' 's#let Tlist_Ctags_Cmd.*#let Tlist_Ctags_Cmd = '"\'${ctags_bin}\'"'#g' ~/.vimrc这...
python 树的遍历 前序遍历 中序遍历 后序遍历 层序遍历 # coding:utf-8"""@ encoding: utf-8@ author: lixiang@ email: lixiang_cn@foxmail.com@ python_version: 2@ time: 2018/4/11 0:09@ more_info:二叉树是有限个元素的集合,该集合或者为空、或者有一个称为根节点(root)的元素及两个互不相交的、分别被称为左...
python 函数传入参数 def test1(data): data += 1 print dataa = 1print atest1(a)print a输出:121def test2(data_list): data_list[0] += 10 print data_listtmplist = [1, 2, 3]print tmplisttes...
python 数据处理 数组拼接concatenate 输入:import numpy as npx = [[1, 2], [3, 4]]x1 = np.concatenate([x, x], axis=0)print("x1 axis=0")print(x1)x2 = np.concatenate([x, x], axis=1)print("x2 axis=1")print(x2)输出:x1 axis=0...
python numpy.newaxis python中numpy.newaxis函数 输入:# a is a lista = np.array([1, 2, 3])# b is a row vectorb = a[np.newaxis]# c is a col vectorc = a[:, np.newaxis]print aprint bprint c输出:# a[1 2 3]# b[[1 2
python list是否包含另一个list所有元素 #!/usr/bin/env python# coding: utf-8a = [1, 2, 3, 4, 5]b = [3, 4, 5]d = [False for c in b if c not in a]if d: print "a不包含b的所有元素"else: print "a包含b的所有元素"也可以考虑转换为set后求交集,看与较小的集合是否相等。
python list是否包含另一个list所有元素 #!/usr/bin/env python# coding: utf-8a = [1, 2, 3, 4, 5]b = [3, 4, 5]d = [False for c in b if c not in a]if d: print "a不包含b的所有元素"else: print "a包含b的所有元素"也可以考虑转换为set后求交集,看与较小的集合是否相等。
python set python的set和其他语言类似, 是一个无序不重复元素集, 基本功能包括关系测试和消除重复元素. 集合对象还支持union(联合), intersection(交), difference(差)和sysmmetric difference(对称差集)等数学运算