读取某个目录下的文件,如'/Users/test/test_kmls'目录下有test1.txt.test2.txt. 第一种方法读出的all_files是test1.txt.test2.txt import os kml_path=os.path.abspath('/Users/test/test_kmls') all_files=os.listdir(kml_path) for file in all_files: print file 第二种方法可以获得文件的全路径,读出的all_file
""" 功能:将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__': [],