在测试以下python代码片段时,我得到python2.7和python3.4的错误:
from datetime import datetime
class Test(object):
def __del__(self):
print(datetime.now().strftime('%Y'))
a = Test()
Error with python2.7:
Exception RuntimeError: 'sys.meta_path must be a list of import hooks' in <bound method Test.__del__ of <__main__.Test object at 0x7f151163b290> ignored
Error with python3.4:
Exception ignored in: <bound method Test.__del__ of <__main__.Test object at 0x7f9a140e1160>>
Traceback (most recent call last):
File "test.py", line 5, in __del__
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2222, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 2155, in _find_spec
TypeError: 'NoneType' object is not iterable
有没有人知道这里发生了什么?删除strftime或用isoformat()替换它似乎运行良好,这真的很奇怪 .