pycharm和idle
请问一下,为什么同样的代码在pycharm和idle里结果却是不一样的这是代码:
class C:
def __getattribute__(self, item):
print('getattribute')
return super().__getattribute__(item)
def __setattr__(self, key, value):
print('setattr')
super().__setattr__(key,value)
def __delattr__(self, item):
print('delattr')
super().__delattr__(item)
def __getattr__(self, item):
print('getattr')
这是在pycharm的结果
>>>c=C()
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattr
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattr
getattribute
这是idle的结果
>>> c=C()
>>> c.x
getattribute
getattr 真的奇怪
VSCODE:PS C:\Users\JHZma\Desktop\pyfiles>${env:DEBUGPY_LAUNCHER_PORT}='1786'; & 'D:\PYTHON\python.exe' 'c:\Users\JHZma\.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy\launcher' 'c:\Users\*\Desktop\pyfiles\temp.py'
PS C:\Users\JHZma\Desktop\pyfiles>${env:DEBUGPY_LAUNCHER_PORT}='1791'; & 'D:\PYTHON\python.exe' 'c:\Users\JHZma\.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy\launcher' 'c:\Users\*\Desktop\pyfiles\temp.py'
PS C:\Users\JHZma\Desktop\pyfiles>${env:DEBUGPY_LAUNCHER_PORT}='1795'; & 'D:\PYTHON\python.exe' 'c:\Users\JHZma\.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy\launcher' 'c:\Users\*\Desktop\pyfiles\temp.py'
PS C:\Users\JHZma\Desktop\pyfiles>${env:DEBUGPY_LAUNCHER_PORT}='1799'; & 'D:\PYTHON\python.exe' 'c:\Users\JHZma\.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy\launcher' 'c:\Users\*\Desktop\pyfiles\temp.py'
PS C:\Users\JHZma\Desktop\pyfiles>${env:DEBUGPY_LAUNCHER_PORT}='1803'; & 'D:\PYTHON\python.exe' 'c:\Users\JHZma\.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy\launcher' 'c:\Users\*\Desktop\pyfiles\temp.py'
PS C:\Users\JHZma\Desktop\pyfiles> IDLE>>> C()
<__main__.C object at 0x000001634BB31E20>
>>> C()
<__main__.C object at 0x000001634BB31FD0>
>>> C()
<__main__.C object at 0x000001634BB31D60>
>>> C()
<__main__.C object at 0x000001634BB31E50>一次都没遇到 https://fishc.com.cn/thread-144747-1-1.html 编译器和原生的 IDLE 还是有区别的…… 编译器的问题吧。。。遇到这种情况是不是要以原生idle为主? 没有,我在idle上运行的结果和你一样,再pycharm运行的结果是末尾在加一个None。
页:
[1]