从回溯导入格式\u exception_only ImportError:无法导入名称“format”“exception”“only”

2024-10-05 13:08:22 发布

您现在位置:Python中文网/ 问答频道 /正文

标题中提到了我的错误。从命令提示符调用代码时。同时在代码后面附加错误路径。我使用的是python3.5.3版本。导入NLTK库时发现错误。在

命令:

Python主测试.py在

代码:

# file name Maintest.py
import sys
#import nltk #on commenting the code runs fine  

an_error = IndexError('tuple index out of range')
print(an_error)

def demorun():
    print("Demo code called")

def main(argv):
    print("Run the demo ")
    demorun()

if __name__ == '__main__':
    main(sys.argv)

错误:

^{pr2}$

Tags: the代码namepyimportanmaindef

热门问题