shell-变量作用域 调用其他脚本中的函数时, 若函数中使用了函数所在文件的变量但是当前sheell脚本并没有导入函数所在脚本, 变会出现可以访问函数但是函数无法访问变量的问题代码示例a.sh#!/bin/bashstr="sss"function getStr(){ echo "str=${str}"}b.sh#!/bin/bash# 导入. ./a.shecho "run getStr in b.sh"getStrecho "run getStr in c.sh"./c.s
GO 类型转换 (*struct)(nil) package mainimport "reflect"type Info struct { Name string}func TestFunc(i interface{}) { configType := reflect.TypeOf(i) println(configType.String())}func main() { TestFunc((*Info)(nil))}输出 *mian.Info
小说下载器 该程序使用了分布式进程的方法,在服务器端发布任务。在多台客户端同时进行下载,大大的提高了下载效率,同时,在对页面进行解析时使用了多个进程,分别用于提取新的URL和章节内容,以下是源码 服务器端源码:给部分源码分为两部分,第一部分为任务发布器,第二部分将各个客户端返回的数据写入TXT文件中第一部分:#coding:utf-8从multiprocessing.managers...
java---迭代器 目录Iterator ListIterator Iterator(单向移动)创建:List<?> list = new ArrayList<?>();Iterator <?> it = list.iterator();判断容器中是否还有元素:it.hasNext();获取元素:it.next();移除元素:(在...
java-工厂模式示例 interface Service{ void method1(); void method2();}interface ServiceFactory{ Service getService();}class Implementation1 implements Service{ Implementation1() { // TODO...
Java 中到底是应该用接口类型 还是实现类的类类型去引用对象? eg//implA 为接口 ClassB为其实现类implA A=new ClassB();//接口类型的引用变量A 去接收对象地址orClassB A=new ClassB();//类类型的引用变量A 去接收对象地址完整文章 :https://blog.csdn.net/summerxiachen/article/details/79733800文章中提到的工厂模式示例:h...
java--内部类中.this与.new用法 .this 生成对外部类的引用public class DotThis { void f(){ System.out.println("DotThis.f()"); } public class Inner{ public DotThis outer(){ return DotThis.this; ...
java--在构造函数中调用其他构造函数 使用 this 关键字public class Flower { int petalCount = 0; String s = "cyl is qingliu"; Flower(int petals){ System.out.println("int"); petalCount = petals; } Flow...
java-标签的使用 public class Test { public static void main(String[] args) { int sum =0; label1: for(int i = 0;i<5;i++){ for(int j = 0; j< 2;j++){ ...
python2.x与3.x区别 1.cpickle 2.x: import cpickle 3.x import _pickle as cPickle2.print 2.x: print "" 3.x: print("")3.
Arrays类-java 1.位置:java,util.Arrays2.Arrays.fill(i, 47); 用数字47将数组i填充3.System.arraycopy(i, 0, j, 0, i.length); 将i中o-i.len的内容复制到j4.Arrays.equals(i, j) 比较两个数组是否相等5.Arrays.deepEquals() 比较多维数...
简单的邮件发送程序-python from email.mime.text import MIMETextfrom email.header import Headerfrom email.utils import parseaddr,formataddrimport smtplibdef _format_addr(s): name,addr = parseaddr(s)#解析邮箱地址 return formatadd...
页面图片爬取-python import urllibfrom lxml import etreeimport requestsdef Schedule(blocknum,blocksize,totalsize): ''' blocknum:已经下载的数据块 blocksize:数据块大小 totalsize:远程文件的大小 ''' per = 100*blocknum* blocksi...