我们在用python进行数据处理时往往需要将文件中的数据取出来做一些处理,这时我们应该注意数据文件的路径.文件路径不对,回报如下错误: FileNotFoundError: File b'..Advertising.csv' does not exist 这里列举几种常见的文件路径 1.当文件在当前目录下时:直接用单引号文件名 import numpy as nppath='testdata.csv'data=np.read_csv(path) 2.文件在上一级目录时:大家注意windows读取
""" 功能:将Excel数据导入到MySQL数据库 """ import xlrd import MySQLdb # Open the workbook and define the worksheet book = xlrd.open_workbook("pytest.xls") sheet = book.sheet_by_name("source") #建立一个MySQL连接 database = M
首先导入scipy的包 from scipy.io import loadmat 然后读取 m = loadmat("F:/__identity/activity/论文/data/D001.mat") 注意这里m是一个dict数据结构 >>> m {'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Mon Aug 15 22:16:43 2011', '__globals__': [],