AttributeError的: - '名單' 對象有沒有屬性 'startswith' 在Django的看法: -AttributeError的: - '名單' 對象有沒有屬性 'startswith' 在Django的看法: -
def index(request):
value = []
path = os.path.join(BASE_DIR,'accessfiles/media/images/GSE2035_series_matrix.txt')
with open(path, 'r', encoding = "utf-8") as file:
file = csv.reader(file, delimiter='\t')
for line in file:
if line.startswith("!Series_relation"):
value = line[1]
args = {'file':value}
return render(request, 'index.html', args)
'csv.reader()'返回列的列表。也不要將兩個不同的對象分配給名爲'file'的var。 – phd