test

函数式编程之参数详解

喜夏-厌秋 提交于 2020-02-06 02:04:38
1、函数的返回值。python返回值比较诡异。呵呵,我人也可以返回,其它的函数,这时会返回函数的内存地值。如return test1. 1 def test1(): 2 print("in the test1") 3 #print("in the test") 4 5 def test2(): 6 print("in the test2") 7 return 0 8 9 def test3(): 10 print("in the test3") 11 12 return 1,'hello',['zfp','lipei'],{'name':'zfp'} 13 #python灵活的返回方式,象超市的购物袋。 14 x=test1() 15 y=test2() 16 z=test3() 17 18 print(x) 19 print(y) 20 print(z) 2、形参与实参。 位置参数与关键字参数,位置参数必须在关键字参数的左边。 1 def test(x,y,z): 2 print(x) 3 print(y) 4 print(z) 5 6 #形参和实参要了解清楚 7 #x=1 8 #y=2 9 #位置参数调用,与形参顺序一一对应。关键字调用,与形参位置无关。只要调用时有逻辑错误,就会报错。关键参数是不能写在位置参数前面的。 10 #test(x=x,y=y) 11 #test(y

C++ #define头文件

走远了吗. 提交于 2020-02-06 01:52:35
写法 要编写头文件test.h,要使用这种写法 #ifndef _TEST_H #define _TEST_H ············ ············ #endif 解释 当我们对程序文件进行编译时,可能会对.h文件重复编译 例如: 当a.cpp中include了b.h和c.h,而b.h和c.h都include了d.h,这时会导致d.h头文件在编译的过程中要被编译两次 为了减少编译次数,提高代码编译效率,我们需要使用#ifndef宏定义命令把头文件内容包起来,这样就能解决这个问题啦 来源: CSDN 作者: 绿竹巷人 链接: https://blog.csdn.net/weixin_42156097/article/details/104189006

MySQL 之全文索引

て烟熏妆下的殇ゞ 提交于 2020-02-06 01:48:18
最近在复习数据库索引部分,看到了 fulltext,也即全文索引,虽然全文索引在平时的业务中用到的不多,但是感觉它有点儿意思,所以花了点时间研究一下,特此记录。 引入 概念 通过数值比较、范围过滤等就可以完成绝大多数我们需要的查询,但是,如果希望通过关键字的匹配来进行查询过滤,那么就需要基于相似度的查询,而不是原来的精确数值比较。全文索引就是为这种场景设计的。 你可能会说,用 like + % 就可以实现模糊匹配了,为什么还要全文索引?like + % 在文本比较少时是合适的,但是对于大量的文本数据检索,是不可想象的。全文索引在大量的数据面前,能比 like + % 快 N 倍,速度不是一个数量级,但是全文索引可能存在精度问题。 你可能没有注意过全文索引,不过至少应该对一种全文索引技术比较熟悉:各种的搜索引擎。虽然搜索引擎的索引对象是超大量的数据,并且通常其背后都不是关系型数据库,不过全文索引的基本原理是一样的。 版本支持 开始之前,先说一下全文索引的版本、存储引擎、数据类型的支持情况 MySQL 5.6 以前的版本,只有 MyISAM 存储引擎支持全文索引; MySQL 5.6 及以后的版本,MyISAM 和 InnoDB 存储引擎均支持全文索引; 只有字段的数据类型为 char、varchar、text 及其系列才可以建全文索引。 测试或使用全文索引时,要先看一下自己的

jQuery 关于文档处理

你离开我真会死。 提交于 2020-02-06 01:25:40
这里介绍一些jQuery关于html的一些操作。 一般获取内容,有三个方法。 text() - 设置或返回所选元素的文本内容 html() - 设置或返回所选元素的内容(包括 HTML 标记) val() - 设置或返回表单字段的值 下面看个实例 <!DOCTYPE html> <html> <head> <script src="/jquery/jquery-1.11.1.min.js"></script> <script> $(document).ready(function(){ $("#btn3").click(function(){ alert("Value: " + $("#test1").val()); //输出表单text的值 val()设置值则替换其中的内容 }); $("#btn1").click(function(){ alert("Text: " + $("#test").text()); //输出文本 text() 设置值则替换其中内容 }); $("#btn2").click(function(){ alert("HTML: " + $("#test").html()); //输出p中的文本还有html标记 HTML()设置值则替换其中的内容 }); }); </script> </head> <body> <p>姓名:<input type="text

TensorFlow keras 迁移学习

空扰寡人 提交于 2020-02-06 01:09:11
数据的读取 import tensorflow as tf from tensorflow.python import keras from tensorflow.python.keras.preprocessing.image import ImageDataGenerator class TransferModel(object): def __init__(self): #标准化和数据增强 self.train_generator = ImageDataGenerator(rescale=1.0/255.0) self.test_generator = ImageDataGenerator(rescale=1.0/255.0) #指定训练集数据和测试集数据目录 self.train_dir = "./data/train" self.test_dir = "./data/test" self.image_size = (224,224) self.batch_size = 32 def get_loacl_data(self): ''' 读取本地的图片数据以及类别 :return: ''' train_gen = self.train_generator.flow_from_directory(self.train_dir, target_size=self.image

A. Array with Odd Sum

ぃ、小莉子 提交于 2020-02-06 00:29:48
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array aa consisting of nn integers. In one move, you can choose two indices 1≤i,j≤n1≤i,j≤n such that i≠ji≠j and set ai:=ajai:=aj. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose ii and jj and replace aiai with ajaj). Your task is to say if it is possible to obtain an array with an odd (not divisible by 22) sum of elements. You have

C. Yet Another Walking Robot Round #617 (Div. 3)()(map + 前后相同状态的存储)

不想你离开。 提交于 2020-02-05 22:51:37
C. Yet Another Walking Robot time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There is a robot on a coordinate plane. Initially, the robot is located at the point (0,0)(0,0). Its path is described as a string 𝑠s of length 𝑛n consisting of characters ‘L’, ‘R’, ‘U’, ‘D’. Each of these characters corresponds to some move: ‘L’ (left): means that the robot moves from the point (𝑥,𝑦)(x,y) to the point (𝑥−1,𝑦)(x−1,y); ‘R’ (right): means that the robot moves from the point (𝑥,𝑦)(x,y) to the point (𝑥+1,𝑦)(x+1,y); ‘U’ (up): means that the robot

Julia ---- 并发编程 @everywhere 和 addprocs 使用顺序

孤街浪徒 提交于 2020-02-05 21:45:52
addprocs 必须是在 @everywhere 的前面,其他一些并行计算的宏也一样,比如 @async 等。 nprocess = 5 addprocs(nprocess) responses = Vector{Any}(nworkers()) @everywhere function test(x) return x * 2.0 end for i in 1:nworkers() responses[i] = remotecall(test, i+1, i) end for res in responses wait(res) end 来源: CSDN 作者: October-- 链接: https://blog.csdn.net/weixin_41715077/article/details/104188678

使程序在Linux下后台运行 (关掉终端继续让程序运行的方法)

馋奶兔 提交于 2020-02-05 21:32:12
你是否遇到过这样的情况:从终端软件登录远程的Linux主机,将一堆很大的文件压缩为一个.tar.gz文件,连续压缩了半个小时还没有完成,这时,突然你断网了,你登录不上远程Linux主机了,那么前面的半个小时就会前功尽弃,你非常气愤…… 在Linux下,如果你要执行的shell命令耗时特别长,并且:(1)你的网络不稳定,随时可能断网;或者(2)你在执行了shell命令之后必须要关闭终端软件(例如SecureCRT)。 那么你就需要以脱离终端的方式在后台运行这个shell命令。 方法如下: (1)输入命令: nohup 你的shell命令 & (2)回车,使终端回到shell命令行; (3)输入exit命令退出终端:exit (4)现在可以关闭你的终端软件了,等过足够的时间,让你的shell命令执行完了再上去看结果吧。 其中,nohup命令可以让你的shell命令忽略SIGHUP信号,即可以使之脱离终端运行;“&”可以让你的命令在后台运行。 以脱离终端的方式在后台运行shell命令有这样几个好处:只要你执行过了命令,那么你的网络中断不会对你有任何影响,并且你就可以关闭终端软件了。 一、为什么要使程序在后台执行 我们计算的程序都是周期很长的,通常要几个小时甚至一个星期。我们用的环境是用putty远程连接到日本Linux服务器。所以使程序在后台跑有以下三个好处: 1

dataguard环境下修改redo log和standby log

一个人想着一个人 提交于 2020-02-05 21:04:33
最近在巡检数据库时,发现一套线上数据库服务器的redo log和standby log设置不符合最佳实践,所以需要联机修改主备库的 redo log和standby log,修改的具体步骤进行了如下的总结。 (1)在主库上切换日志,查看主备同步状态,查看主备同步是否正常,参考此篇文章( https://blog.csdn.net/weixin_41561862/article/details/104185660 )。 alter system switch logfile; alter system switch logfile; alter system switch logfile; alter system checkpoint; (2)如果主备日志同步正常,先取消备库的实时应用,设置主库和备库的standby_file_management参数为manual。 备库上先取消实时应用: alter database recover managed standby database cancel; 主备库执行: alter system set standby_file_management='manual'; (3)查看主库redo日志的情况,修改主库redo log。 select GROUP#,THREAD#,STATUS from v$log;