python day4 python调用同一目录/路径的另一个模块中的函数

在 python 中,每一个 py 文件都称为模块,每一个具有 __init__.py 文件的目录称为包。

Python中提供了list容器,可以当作数组使用。但列表中的元素可以是任何对象,因此列表中保存的是对象的指针,这样一来,为了保存一个简单的列表[1,2,3]。就需要三个指针和三个整数对象。对于数值运算来说,这种结构显然不够高效。

Python虽然也提供了array模块,但其只支持一维数组,不支持多维数组(在TensorFlow里面偏向于矩阵理解),也没有各种运算函数。因而不适合数值运算。

NumPy的出现弥补了这些不足。

lambda表达式,通常是在需要一个函数,但是又不想费神去命名一个函数的场合下使用,也就是指匿名函数。

lambda所表示的匿名函数的内容应该是很简单的,如果复杂的话,干脆就重新定义一个函数了,使用lambda就有点过于执拗了。

lambda就是用来定义一个匿名函数的,如果还要给他绑定一个名字的话,就会显得有点画蛇添足,通常是直接使用lambda函数。如下所示:

add = lambda x, y : x+y
add(1,2) # 结果为3
python调用同一目录/路径的另一个模块中的函数

lambda是一个表达式,而不是一个语句(lambda is an expression, not a statement.)因此,lambda能够出现在Python语法不允许def出现的地方——例如,在一个列表常量中或者函数调用的参数中。

lambda的主体是一个单个的表达式,而不是一个代码块。(lambda’s body is a single expression, not a block of statements.),lambda里面的语句相当于def中return中的代码一样。只能是简单的表达式,所以说lambda的能力小于def,在lambda中只能使用简单的语法,不能使用if else while return等语句

它的设计理念为:lambda是一个为编写简单的函数而设计的,而def用来处理更大的任务。(lambda is designed for coding simple functions, and def handles larger tasks.)

.py 文件是一个模块, 里面可以定义类和函数,也可以只定义函数, 我这里模块名字和函数名字一样,但调用还是必须按照格式: 从···模块import····函数

所以同一名字写两次
在这里插入图片描述

The Pearson correlation coefficient measures the linear relationship
between two datasets. Strictly speaking, Pearson’s correlation requires
that each dataset be normally distributed, and not necessarily zero-mean.
Like other correlation coefficients, this one varies between -1 and +1
with 0 implying no correlation. Correlations of -1 or +1 imply an exact
linear relationship. Positive correlations imply that as x increases, so
does y. Negative correlations imply that as x increases, y decreases.

The p-value roughly indicates the probability of an uncorrelated system
producing datasets that have a Pearson correlation at least as extreme
as the one computed from these datasets. The p-values are not entirely
reliable but are probably reasonable for datasets larger than 500 or so.

anaconda安装minepy包

下载地址: Unofficial Windows Binaries for Python Extension Packages

根据自己的安装版本选择下载哪一个,下错了会出错 is not a supported wheel on this platform,下面可以看到
在这里插入图片描述
在这里插入图片描述
下载好随便放在哪里都行,我放在 C:\Users\Administrator\AppData\Roaming\Python\Python37\Scripts

在anaconda propmt里执行pip install命令, 不用pip3

(base) C:\Users\Administrator>pip3 install minepy-1.2.4-cp37-cp37m-win32.whl
'pip3' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

(base) C:\Users\Administrator>pip C:\Users\Administrator\AppData\Roaming\Python\Python37\Scripts\install minepy-1.2.4-cp37-cp37m-win32.whl
ERROR: unknown command "C:\Users\Administrator\AppData\Roaming\Python\Python37\Scripts\install"

(base) C:\Users\Administrator>pip install C:\Users\Administrator\AppData\Roaming\Python\Python37\Scripts\minepy-1.2.4-cp37-cp37m-win32.whl
ERROR: minepy-1.2.4-cp37-cp37m-win32.whl is not a supported wheel on this platform.

(base) C:\Users\Administrator>pip install C:\Users\Administrator\AppData\Roaming\Python\Python37\Scripts\minepy-1.2.4-cp37-cp37m-win_amd64.whl
Processing c:\users\administrator\appdata\roaming\python\python37\scripts\minepy-1.2.4-cp37-cp37m-win_amd64.whl
Requirement already satisfied: numpy>=1.3.0 in d:\programdata\anaconda3\lib\site-packages (from minepy==1.2.4) (1.16.4)
Installing collected packages: minepy
Successfully installed minepy-1.2.4

(base) C:\Users\Administrator>

控制台输入命令

conda install -c conda-forge minepy

自动弹出命令行并下载,,,,,没成功,各种fail,上面那个妥妥的,已经开始使用啦

发布了190 篇原创文章 · 获赞 65 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/qq_36607894/article/details/102935810
今日推荐