python - 运行 python runserver --nothreading -noreload 时出错
问题描述
/home/saumen/.local/lib/python2.7/site-packages/django/core/management/__init__.py:316: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if subcommand == 'runserver' and '--noreload' not in self.argv:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/saumen/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/saumen/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/saumen/.local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/saumen/.local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 61, in execute
super(Command, self).execute(*args, **options)
File "/home/saumen/.local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/saumen/.local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 86, in handle
'or address:port pair.' % options['addrport'])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
运行 python runserver --nothreading -noreload 时出现错误。我该怎么办?我已经安装了 mysqlclient 和必要的 python 库。
解决方案
首先编辑您的答案并将代码放在第 86 行...由于 UnicodeDecodeError 而发生错误:
这可能对您有用:(注意:your_string 是您要解码的内容)
your_String.encode('ascii', 'ignore').decode('utf-8')
对于更具体的问题:
str(options['addrport']).encode('ascii', 'ignore').decode('utf-8')
推荐阅读
- xslt-3.0 - 从 xml 文件中提取某种语言的单词
- javascript - e.Row.Attributes 在回发后不起作用
- python - 在下一个可用单元格 csv 中写入值
- visual-studio - Visual Studio 2017 项目中隐藏的文件夹
- android - 媒体播放器点击 14 次后停止工作
- php - 更改电子邮件验证错误消息 Laravel 5.7
- python - 在不丢失细节的情况下减小图像大小
- javascript - 如何检查 HTML 属性是真还是假?
- laravel - fontawesome-vue 组件图标切换无法正常工作
- kubernetes - 如何在 Windows 上为 Google Cloud Platform 添加 docker-registry 密码(即在 PowerShell 中,而不是 Bash 中)?