下面是一个获取配置的代码 def getValue(self,section,option): """ @file: string,the name of the config file @section: string,the name of the section in config file @option: string,the name of the option in section field This function will return a int va
我们在用python进行数据处理时往往需要将文件中的数据取出来做一些处理,这时我们应该注意数据文件的路径.文件路径不对,回报如下错误: FileNotFoundError: File b'..Advertising.csv' does not exist 这里列举几种常见的文件路径 1.当文件在当前目录下时:直接用单引号文件名 import numpy as nppath='testdata.csv'data=np.read_csv(path) 2.文件在上一级目录时:大家注意windows读取
file_path =(r'i:\vacpy\ch10\pi_digits.txt') #将文件路径存储在变量file_path中with open (file_path) as file_object: contents = file_object.read() print(contents) """windows system 有时能够正确地解读文件路径中的斜杆.如果你使用的是windows system,且结果不符合预期,请确保文件路径中使用的是反斜杆.另外,由于反斜杆