Yahoo 知識+ 將於 2021 年 5 月 4 日 (美國東岸時間) 停止服務,而 Yahoo 知識+ 網站現已轉為僅限瀏覽模式。其他 Yahoo 資產或服務,或你的 Yahoo 帳戶將不會有任何變更。你可以在此服務中心網頁進一步了解 Yahoo 知識+ 停止服務的事宜,以及了解如何下載你的資料。
Python question. Syntax error?
I'm new to Python and I have an example script that has a syntax error, but I can't see what's wrong. Here it is:
class SimpleGraph:
def __init__(self):
self._spo = {}
self._pos = {}
self._osp = {}
def add(self, (sub, pred, obj)):
I get a syntax error on the ( before sub. I'm running Python 3.1. Any ideas?
1 個解答
- SilentLv 71 十年前最愛解答
Why do you have parentheses around the last three parameters to the add function?
If you're trying to make the function take a tuple as a parameter, you can't do it that way in Python 3. That was possible in previous versions of Python, but not anymore.
Python 3 and Python 2 are not compatible languages. If you're running Python 3, don't use example code written for Python 2; you'll just end up with a lot of confusion and things that don't work.