ImportError: cannot import name 'ascii_letters' from 'string' python debug報錯

Traceback (most recent call last):
  File "D:\Python\Pycharm\PyCharm Community Edition with Anaconda plugin 2019.2.2\helpers\pydev\pydevd.py", line 20, in <module>
    from _pydevd_bundle.pydevd_constants import IS_JYTH_LESS25, IS_PYCHARM, get_thread_id, get_current_thread_id, \
  File "D:\Python\Pycharm\PyCharm Community Edition with Anaconda plugin 2019.2.2\helpers\pydev\_pydevd_bundle\pydevd_constants.py", line 179, in <module>
    from _pydev_imps._pydev_saved_modules import thread
  File "D:\Python\Pycharm\PyCharm Community Edition with Anaconda plugin 2019.2.2\helpers\pydev\_pydev_imps\_pydev_saved_modules.py", line 21, in <module>
    import xmlrpc.client as xmlrpclib
  File "D:\Python\Python\lib\xmlrpc\client.py", line 136, in <module>
    import http.client
  File "D:\Python\Python\lib\http\client.py", line 71, in <module>
    import email.parser
  File "D:\Python\Python\lib\email\parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "D:\Python\Python\lib\email\feedparser.py", line 27, in <module>
    from email._policybase import compat32
  File "D:\Python\Python\lib\email\_policybase.py", line 7, in <module>
    from email import header
  File "D:\Python\Python\lib\email\header.py", line 16, in <module>
    import email.quoprimime
  File "D:\Python\Python\lib\email\quoprimime.py", line 44, in <module>
    from string import ascii_letters, digits, hexdigits
ImportError: cannot import name 'ascii_letters' from 'string' (D:\Python\Project\string.py)

出錯原因:

項目文件中有文件名是string.py的文件

解決方法:

把文件名替換成其他的就可以了    比如首字母大寫String.py

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章