ฉันมีรายการ synsets ต่อไปนี้ใน python:
string = ["Synset('bank.n.01')", "Synset('computer.n.01')", "Synset('work.v.02')", "Synset('super.a.01')"]
และฉันกำลังพยายามรวมคำจำกัดความของแต่ละบุคคลในลักษณะดังต่อไปนี้:
string1 = ""
for w in string:
string1 = string1 + w.definition
แต่มันทำให้ฉันมีข้อผิดพลาดดังต่อไปนี้:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
AttributeError: 'str' object has no attribute 'definition'
แต่ถ้าฉันทำ
for w in wn.synsets("bank"):
print w.definition
มันทำงานได้สำเร็จและให้ผลลัพธ์ที่ถูกต้อง โปรดบอกฉันว่าฉันควรทำอย่างไร?