如何修复';语法错误';在python的itertools模块中?

如何修复';语法错误';在python的itertools模块中?,python,python-2.7,Python,Python 2.7,我一直在尝试定义一个未来个人使用的a。我以前试过,但部分成功,它不会打印排列。只是一个内存地址。我试图找到排列列表,但它没有出现。我甚至使用了内存地址,屏幕上也出现了同样的东西 >>> a == itertools.permutations(['+', '$', '#']): File "<stdin>", line 1 a == itertools.permutations(['+', '$', '#']):

我一直在尝试定义一个未来个人使用的a。我以前试过,但部分成功,它不会打印排列。只是一个内存地址。我试图找到排列列表,但它没有出现。我甚至使用了内存地址,屏幕上也出现了同样的东西

   >>> a == itertools.permutations(['+', '$', '#']):
      File "<stdin>", line 1
        a == itertools.permutations(['+', '$', '#']):
                                                    ^
    SyntaxError: invalid syntax
    >>> a = itertools.permutations(['+', '$', '#']):
      File "<stdin>", line 1
        a = itertools.permutations(['+', '$', '#']):
                                                   ^
    SyntaxError: invalid syntax
>a==itertools.permutations(['+','$','#']):
文件“”,第1行
a==itertools.permutations(['+','$','#']):
^
SyntaxError:无效语法
>>>a=itertools.permutations(['+','$','#']):
文件“”,第1行
a=itertools.permutations(['+','$','#']):
^
SyntaxError:无效语法
-

>>打印一个
>>>ctypes.cast(一个,ctypes.py_对象).value
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/usr/lib/python2.7/ctypes/_init__.py”,第503行,在cast中
返回式铸造(obj,obj,典型)
ctypes.ArgumentError:参数1::错误类型

第二行更接近您想要的内容。你只需要从末端去掉冒号。请注意,
=
用于为变量赋值,而
=
用于比较两个值。

删除冒号
a==itertools。排列(['+','$','#']):
没有意义,您试图将其用作条件;删除冒号不会有帮助,因为这样你只会得到一个布尔值,它可能不可能是真的。我假设您希望分配
=
,而不是用于比较的
=
。如果确实要检查是否相等,则需要一个
If
@roganjosh注意,这似乎是一个交互式REPL会话,并且输入的代码中没有
If
。@code student enter。我编辑:)你到底想在这里做什么?有什么样的比较需要做,或者你只是想要结果?
>>> print a
<itertools.permutations object at 0x7eff4c8ede90>
>>>ctypes.cast(a, ctypes.py_object).value

 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib/python2.7/ctypes/__init__.py", line 503, in cast
 return _cast(obj, obj, typ)
 ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: wrong type