Python入门级报错的处理方法

Python入门级报错的处理方法,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名、网页空间、营销软件、网站建设、泊头网站维护、网站推广。

问题1:Missing parentheses in call to 'print'

原因:因为Python2.X和Python3.X不兼容。
我安装的是Python3.X,但是我试图运行的却是Python2.X 的代码。
所以上面的语法在python3中是错误的。在python3中,你需要将print后面的语句加括号,正确的写法:
print ("hello world")


问题2:创建项目报错,django-admin startproject sundyblog 
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\django\utils\html.py", line 16, in <module>
from .html_parser import HTMLParser, HTMLParseError
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\django\utils\html_parser.py", line 12, in <module>
HTMLParseError = _html_parser.HTMLParseError
AttributeError: module 'html.parser' has no attribute 'HTMLParseError'


原因:HTMLParseError在pythons3.5已经没有了

解决方法:

方法1:将python版本回退到3.3或3.4

方法2:升级django版本
>pip3 install django==1.8 ##升级django版本
C:\Users\andy>django-admin startproject sundyblog ##再次执行,无报错

问题3: 使用  ImageField  字段建表报错

C:\Users\andy\sundyblog>python manage.py makemigrations
SystemCheckError: System check identified some issues:

ERRORS:
blog.Article.portal: (fields.E210) Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install Pillow".

解决:C:\Users\andy\sundyblog>pip install -i https://pypi.douban.com/simple/ Pillow
Looking in indexes: https://pypi.douban.com/simple/
Collecting Pillow
Downloading https://pypi.doubanio.com/packages/0f/fe/0979c8d6fa0c986e4603e5396904945b44f93ff9e346ee5ffadc7487cff6/Pillow-5.4.1-cp35-cp35m-win32.whl
100% |████████████████████████████████| 1.7MB 351kB/s
Installing collected packages: Pillow
Successfully installed Pillow-5.4.1
You are using pip version 19.0.1, however version 19.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\Users\andy\sundyblog>python manage.py makemigrations
Migrations for 'blog':
0001_initial.py:
- Create model Article
- Create model Author
- Add field autor to article

C:\Users\andy\sundyblog>

看完上述内容,你们掌握Python入门级报错的处理方法的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!

网站题目:Python入门级报错的处理方法
网站路径:https://www.cdcxhl.com/article36/pggppg.html

成都网站建设公司_创新互联,为您提供外贸网站建设网站设计公司Google网站策划定制开发建站公司

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

外贸网站建设