我正在嘗試讀取 .csv 文件并收到此錯(cuò)誤ValueError: could not convert string to float: '???220'到目前為止,這是我的代碼:import csvimport matplotlibimport osenvironment = []# Initialise data dirdir = os.getcwd()print(dir)parent = os.path.dirname(dir)parent = os.path.dirname(parent)parent = os.path.dirname(parent)basedir = os.path.dirname(parent)print(basedir)datadir = os.path.join(basedir, 'data')print(datadir)inputdatadir = os.path.join(datadir, 'input')print(inputdatadir)# Open file and read.file = os.path.join(inputdatadir, 'snowslope1.csv')f = open(file, newline='') reader = csv.reader(f, quoting=csv.QUOTE_NONNUMERIC)for row in reader: # A list of rows rowlist = [] for value in row: # A list of value rowlist.append(value) #print(value) environment.append(rowlist)f.close()# Plot environment.matplotlib.pyplot.imshow(environment)matplotlib.pyplot.show()有人可以幫忙解決這里出了什么問題嗎?我不確定錯(cuò)誤在哪里,因?yàn)樗鼈兯坪醵贾皇沁@樣的數(shù)字:我的文件 Snowslope1.csv 中的 220,221,222,223
添加回答
舉報(bào)
0/150
提交
取消