把变量,比如矩阵的值存储到文件里面去

然后会生成以npy结尾的文件 'outpagerank.txt.npy,那我们想知道其值是多少,就是还是得用numpy打开:操作如下:

>>> import numpy as np
>>> res =np.load('outpagerank.txt.npy')
>>> print(res)
[[1. 0.42473167 0.43114048 0.4327292 0.41764748 0.43516319
0.44106397 0.44462173 0.50331293 0.45362872 0.44292297 0.46426437
0.43707794 0.45615803 0.42983198]
[0.42473167 1. 0.45839741 0.42719571 0.40428848 0.43837253
0.44429348 0.4337702 0.44253535 0.44791153 0.43353619 0.44429414
0.43068321 0.43906305 0.42371578]
[0.43114048 0.45839741 1. 0.42230247 0.40309924 0.42420185
0.43543933 0.43437472 0.43895638 0.44455397 0.44456802 0.44256433
0.42793962 0.42935008 0.42239323]
[0.4327292 0.42719571 0.42230247 1. 0.44279766 0.43711807
0.43766713 0.4440511 0.43688561 0.44120794 0.4377073 0.43951285
0.44332548 0.45266624 0.5948263 ]
[0.41764748 0.40428848 0.40309924 0.44279766 1. 0.42047584
0.41520362 0.4251346 0.41306763 0.4129708 0.41485392 0.4106679
0.41663989 0.42814863 0.42586853]
[0.43516319 0.43837253 0.42420185 0.43711807 0.42047584 1.
0.51644062 0.48621236 0.50311374 0.4834296 0.48030702 0.49583616
0.46070994 0.50916625 0.43578949]
[0.44106397 0.44429348 0.43543933 0.43766713 0.41520362 0.51644062
1. 0.53027005 0.50421091 0.50138658 0.5119342 0.53760351
0.47057133 0.50916768 0.43533346]
[0.44462173 0.4337702 0.43437472 0.4440511 0.4251346 0.48621236
0.53027005 1. 0.489522 0.50415135 0.4859528 0.49838435
0.46368942 0.51125547 0.43601848]
[0.50331293 0.44253535 0.43895638 0.43688561 0.41306763 0.50311374
0.50421091 0.489522 1. 0.5116941 0.48656104 0.55068073
0.46370181 0.51195915 0.46149022]
[0.45362872 0.44791153 0.44455397 0.44120794 0.4129708 0.4834296
0.50138658 0.50415135 0.5116941 1. 0.47217986 0.52467429
0.46565433 0.50100535 0.43424123]
[0.44292297 0.43353619 0.44456802 0.4377073 0.41485392 0.48030702
0.5119342 0.4859528 0.48656104 0.47217986 1. 0.5248177
0.47804572 0.50011358 0.43193431]
[0.46426437 0.44429414 0.44256433 0.43951285 0.4106679 0.49583616
0.53760351 0.49838435 0.55068073 0.52467429 0.5248177 1.
0.47613601 0.50932056 0.42945853]
[0.43707794 0.43068321 0.42793962 0.44332548 0.41663989 0.46070994
0.47057133 0.46368942 0.46370181 0.46565433 0.47804572 0.47613601
1. 0.49298706 0.43234344]
[0.45615803 0.43906305 0.42935008 0.45266624 0.42814863 0.50916625
0.50916768 0.51125547 0.51195915 0.50100535 0.50011358 0.50932056
0.49298706 1. 0.43796378]
[0.42983198 0.42371578 0.42239323 0.5948263 0.42586853 0.43578949
0.43533346 0.43601848 0.46149022 0.43424123 0.43193431 0.42945853
0.43234344 0.43796378 1. ]]
>>> np.var(res)  
0.019549201600693122
>>> np.std(res)/np.mean(res)
0.2829044699631161

原文地址:https://www.cnblogs.com/www-caiyin-com/p/9441856.html