在Spyder iPython控制台中:
print(sys.version)
3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
,在Ubuntu GNOME终端3.18.3中:
rappleto:~$ python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
如此相同的Python版本和构建
在Spyder中:
In [4]: with open("pid.cpp") as pidcpp:
...: data=pidcpp.read()
...: print(data)
...:
// pid.cpp - author: rappleto
#include <PID_v1.h>
...
终端:
>>> with open("pid.cpp") as pidcpp:
... data=pidcpp.read()
... print(data)
File "<stdin>", line 3
print(data)
^
SyntaxError: invalid syntax
是否有一些特殊方法可以在终端中结束“with”语句?