pep

爬虫(107)Python 3.7的超酷新功能(接近一万字,请耐心享用,而且建议收藏)...

若如初见. 提交于 2020-08-09 01:56:14
Python 3.7 正式发布 ! 这个新的Python版本自 2016 年 9月 开始开发 ,现在我们所有人都可以享受核心开发人员辛勤工作的成果。 新的Python版本带来了什么? 尽管 文档 很好地概述了这些新功能,但本文将深入探讨一些重大新闻。 这些包括: 通过新的 breakpoint() 内置功能 更轻松地访问调试器 使用数据类创建简单的类 定制访问模块属性 改进了对类型提示的支持 高精度计时功能 更重要的是,Python 3.7速度很快 在本文的最后几节中,您将了解有关此速度的更多信息,以及Python 3.7的其他一些出色功能。 您还将获得有关升级到新版本的一些建议 内置的 breakpoint() 断点函数 虽然我们可能会努力编写完美的代码,但简单的事实是我们从不这样做。 调试是编程的重要组成部分。 Python 3.7引入了新的内置函数 breakpoint() 。 这实际上并没有向Python添加任何新功能,但是它使调试器的使用更加灵活和直观。 假设文件中包含以下错误代码 bugs.py : def divide(e, f): return f / e a, b = 0, 1 print(divide(a, b)) 运行代码会导致 函数 ZeroDivisionError 内部 divide() 。 假设您要中断代码并 直接在的顶部 放入 调试器 divide(

Sublime Text3的安装以及python开发环境的搭建

孤街醉人 提交于 2020-08-07 18:07:26
作者: struct_mooc 博客地址: https://www.cnblogs.com/structmooc/p/12376601.html 目录 一. Sublime text3的安装 1.sublime text3下载 2. sublime text3安装 二. 搭建python开发环境 1.python运行环境设置 2.插件管理包Package Control 3.插件安装 1)ConvertToUTF8 2)SublimeREPL 3)SideBarEnhancements 4)AutoPep8 5)Alignment 6)FileHeader 7)Anaconda 8)BracketHighlighter 9)ChineseLocalizations 10)Colorsublime 11)TrailingSpaces 4.查询已安装的插件 5.删除已安装的插件 附:插件作用说明 1)ConvertToUTF8 2)SublimeREPL 3)SideBarEnhancements 4)AutoPep8 5)Alignment 6)FileHeader 7)Anaconda 8)BracketHighlighter 9)ChineseLocalizations 10)Colorsublime 11)TrailingSpaces 一. Sublime text3的安装 1

Sublime Text3的安装以及python开发环境的搭建

本秂侑毒 提交于 2020-08-07 13:08:56
作者: struct_mooc 博客地址: https://www.cnblogs.com/structmooc/p/12376601.html 目录 一. Sublime text3的安装 1.sublime text3下载 2. sublime text3安装 二. 搭建python开发环境 1.python运行环境设置 2.插件管理包Package Control 3.插件安装 1)ConvertToUTF8 2)SublimeREPL 3)SideBarEnhancements 4)AutoPep8 5)Alignment 6)FileHeader 7)Anaconda 8)BracketHighlighter 9)ChineseLocalizations 10)Colorsublime 11)TrailingSpaces 4.查询已安装的插件 5.删除已安装的插件 附:插件作用说明 1)ConvertToUTF8 2)SublimeREPL 3)SideBarEnhancements 4)AutoPep8 5)Alignment 6)FileHeader 7)Anaconda 8)BracketHighlighter 9)ChineseLocalizations 10)Colorsublime 11)TrailingSpaces 一. Sublime text3的安装 1

pip failing to build wheels for scipy

旧街凉风 提交于 2020-08-07 07:50:05
问题 I've just downloaded the new python 3.8 and I'm trying to install the scipy package using the following: pip3.8 install scipy However the build fails with the following error: **Failed to build scipy** **ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly** How can I install this using pip ? I tried using the --no-binary version: pip3.8 install --no-binary :all: scipy but ended up with an even scarier error: **ERROR: Command errored out with exit status

pip failing to build wheels for scipy

≡放荡痞女 提交于 2020-08-07 07:45:50
问题 I've just downloaded the new python 3.8 and I'm trying to install the scipy package using the following: pip3.8 install scipy However the build fails with the following error: **Failed to build scipy** **ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly** How can I install this using pip ? I tried using the --no-binary version: pip3.8 install --no-binary :all: scipy but ended up with an even scarier error: **ERROR: Command errored out with exit status

Sublime Text3的安装以及python开发环境的搭建

旧城冷巷雨未停 提交于 2020-08-07 02:22:10
作者: struct_mooc 博客地址: https://www.cnblogs.com/structmooc/p/12376601.html 目录 一. Sublime text3的安装 1.sublime text3下载 2. sublime text3安装 二. 搭建python开发环境 1.python运行环境设置 2.插件管理包Package Control 3.插件安装 1)ConvertToUTF8 2)SublimeREPL 3)SideBarEnhancements 4)AutoPep8 5)Alignment 6)FileHeader 7)Anaconda 8)BracketHighlighter 9)ChineseLocalizations 10)Colorsublime 11)TrailingSpaces 4.查询已安装的插件 5.删除已安装的插件 附:插件作用说明 1)ConvertToUTF8 2)SublimeREPL 3)SideBarEnhancements 4)AutoPep8 5)Alignment 6)FileHeader 7)Anaconda 8)BracketHighlighter 9)ChineseLocalizations 10)Colorsublime 11)TrailingSpaces 一. Sublime text3的安装 1

Python新手学习标准库模块命名

a 夏天 提交于 2020-08-06 01:20:29
与 Python 标准库模块命名冲突 Python的一个优秀的地方在于它提供了丰富的库模块。但是这样的结果是,如果你不下意识的避免,很容易你会遇到你自己的模块的名字与某个随Python附带的标准库的名字冲突的情况(比如,你的代码中可能有一个叫做email.py的模块,它就会与标准库中同名的模块冲突)。 这会导致一些很粗糙的问题,例如当你想加载某个库,这个库需要加载Python标准库里的某个模块,结果呢,因为你有一个与标准库里的模块同名的模块,这个包错误的将你的模块加载了进去,而不是加载Python标准库里的那个模块。这样一来就会有麻烦了。 所以在给模块起名字的时候要小心了,得避免与Python标准库中的模块重名。相比起你提交一个“Python改进建议(Python Enhancement Proposal (PEP))”去向上要求改一个标准库里包的名字,并得到批准来说,你把自己的那个模块重新改个名字要简单得多。 知识点扩充: python标准库简介 文本 string:通用字符串操作 re:正则表达式操作 difflib:差异计算工具 textwrap:文本填充 unicodedata:Unicode字符数据库 stringprep:互联网字符串准备工具 readline:GNU按行读取接口 rlcompleter:GNU按行读取的实现函数 二进制数据 struct

Python`如果x不是None`或`if not x is None`?

微笑、不失礼 提交于 2020-08-05 12:30:56
问题: I've always thought of the if not x is None version to be more clear, but Google's style guide and PEP-8 both use if x is not None . 我一直认为 if not x is None 版本更清楚,但谷歌的 风格指南 和 PEP-8 都使用, if x is not None 。 Is there any minor performance difference (I'm assuming not), and is there any case where one really doesn't fit (making the other a clear winner for my convention)?* 是否存在任何轻微的性能差异(我假设没有),是否存在任何一个真正不合适的情况(使另一个成为我公约的明显赢家)?* *I'm referring to any singleton, rather than just None . *我指的是任何单身人士,而不仅仅是 None 。 ...to compare singletons like None. ...比较像无的单身人士。 Use is or is not. 使用是否。 解决方案: 参考一:

在现代Python中声明自定义异常的正确方法?

寵の児 提交于 2020-08-05 11:50:12
问题: What's the proper way to declare custom exception classes in modern Python? 在现代Python中声明自定义异常类的正确方法是什么? My primary goal is to follow whatever standard other exception classes have, so that (for instance) any extra string I include in the exception is printed out by whatever tool caught the exception. 我的主要目标是遵循其他异常类具有的任何标准,以便(例如)我捕获到异常中的任何工具都会打印出我包含在异常中的任何多余字符串。 By "modern Python" I mean something that will run in Python 2.5 but be 'correct' for the Python 2.6 and Python 3.* way of doing things. “现代Python”是指可以在Python 2.5中运行但对于Python 2.6和Python 3. *是“正确”的方式。 And by "custom" I mean an

Sublime Text3的安装以及python开发环境的搭建

社会主义新天地 提交于 2020-08-05 03:26:58
作者: struct_mooc 博客地址: https://www.cnblogs.com/structmooc/p/12376601.html 目录 一. Sublime text3的安装 1.sublime text3下载 2. sublime text3安装 二. 搭建python开发环境 1.python运行环境设置 2.插件管理包Package Control 3.插件安装 1)ConvertToUTF8 2)SublimeREPL 3)SideBarEnhancements 4)AutoPep8 5)Alignment 6)FileHeader 7)Anaconda 8)BracketHighlighter 9)ChineseLocalizations 10)Colorsublime 11)TrailingSpaces 4.查询已安装的插件 5.删除已安装的插件 附:插件作用说明 1)ConvertToUTF8 2)SublimeREPL 3)SideBarEnhancements 4)AutoPep8 5)Alignment 6)FileHeader 7)Anaconda 8)BracketHighlighter 9)ChineseLocalizations 10)Colorsublime 11)TrailingSpaces 一. Sublime text3的安装 1