语法错误无效 - Python 3.5.2 Django 1.10

时间:2016-08-05 18:06:57

标签: syntax-error python-3.5

Python / Django新手在这里。我使用以下代码得到语法错误,任何人都可以帮助我吗? IDLE3在之前突出了16号线“宝藏”(“Fool's Gold”)。

from django.shortcuts import render

# Create your views here.
def index(request):
    return render(request, 'index.html', {'treasures':treasures})

class Treasure:
    def __init__(self, name, value, material, location):
        self.name = name
        self.value = value
        self.material = material
        self.location = location

treasures = [
    Treasure('Gold Nugget', 500.00, 'gold', "Curley's Creek, NM")
    Treasure("Fool's Gold", 0, 'pyrite', "Fool's Falls, CO")
    Treasure('Coffee Can', 20.00, 'tin', 'Acme, CA')
]

1 个答案:

答案 0 :(得分:0)

你忘了在数组元素之后加逗号。像这样:

treasures = [
    Treasure('Gold Nugget', 500.00, 'gold', "Curley's Creek, NM"),
    Treasure("Fool's Gold", 0, 'pyrite', "Fool's Falls, CO"),
    Treasure('Coffee Can', 20.00, 'tin', 'Acme, CA')
]