import numpy as np
import sys
import os
class Logger(object):
def __init__(self, filename="Default.log"):
self.terminal = sys.stdout
self.log = open(filename, "a")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
def flush(self):
pass
path = os.path.abspath(os.path.dirname(__file__))
test = np.load('data/glove6b_init_300d.npy')
type = sys.getfilesystemencoding()
sys.stdout = Logger('a.txt')
print(path)
print(test)
print(os.path.dirname(__file__))
print('---------------------------------------')
如果是npy文件
只需要加一行:
np.set_printoptions(threshold=np.inf)
参考:https://blog.csdn.net/weixin_45347379/article/details/110819928