我拿了一些在django 1.8.4版本中創建的示例代碼,並且像Python 2.7一樣轉移到3 python時全都飛走了,併產生了這樣的錯誤,如何解決它?的代碼ImportError:無法導入名稱'StringType'
\lib\site-packages\config.py", line 91, in <module>
from types import StringType, UnicodeType
ImportError: cannot import name 'StringType'
一體其中使用stringtype(config.py)(在站點包)
def writeValue(self, value, stream, indent):
if isinstance(self, Mapping):
indstr = ' '
else:
indstr = indent * ' '
if isinstance(value, Reference) or isinstance(value, Expression):
stream.write('%s%r%s' % (indstr, value, NEWLINE))
else:
if (type(value) is StringType): # and not isWord(value):
value = repr(value)
stream.write('%s%s%s' % (indstr, value, NEWLINE))
你能提供你的代碼嗎?謝謝! –
您是否看到他所在的位置? – InvictusManeoBart
其實,你可能需要修改你的代碼(移植到python 3)。爲了幫助你:https://docs.python.org/3/howto/pyporting.html – iFlo