以下代码在pycharm中有效,但在jupyter notebook中生成错误。
请解释,为什么?
代码:
code = '''
x = 10
y = 10
print(x+y)
'''
exec(code)
错误:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-653-af591d5d8ad2> in <module>() 7 ''' 8 ----> 9 exec(code) TypeError: 'str' object is not callable