python导入外部包_您会喜欢的10个外部Python软件包
python导入外部包
by Adam Goldschmidt
亚当·戈德施密特(Adam Goldschmidt)
您会喜欢的10个外部Python软件包 (10 External Python packages you are going to love)
Python is an experiment in how much freedom programmers need. Too much freedom and nobody can read another’s code; too little and expressiveness is endangered. - Guido van Rossum
Python是程序员需要多少自由度的实验。 太多的自由,没人能读懂别人的密码。 太少,表现力受到威胁。 -Guido van Rossum
This freedom that Guido talks about is part of what makes Python so popular. That popularity, among other, is what attracts more and more developers to use the language - eventually leading to some really amazing open source projects.
Guido谈论的这种自由是使Python如此受欢迎的部分原因。 这种受欢迎程度尤其吸引了越来越多的开发人员使用该语言-最终导致了一些非常出色的开源项目。
I usually find myself project hunting on GitHub once a day. Throughout this article, I will try to cover 10 wonderful packages that you may or may not be familiar with. I will start from the less trendy and end up with… well, Flask.
我通常每天发现自己在GitHub上进行一次项目狩猎。 在本文中,我将尝试介绍您可能熟悉或可能不熟悉的10个出色的程序包。 我将从比较不流行的事物开始,最后以…好吧,Flask。
让我们开始! (Let’s begin!)
Loguru-轻松记录 (Loguru — Logging made easy)
This is a really awesome package I regularly use in my projects. It describes itself as “a library which aims to bring enjoyable logging in Python”. This package just lets you easily configure your logs out of the box.
这是我在项目中经常使用的非常棒的软件包。 它将自己描述为“一个旨在以Python带来令人愉悦的日志记录的库”。 该软件包使您可以轻松地开箱即用地配置日志。
All you have to do after installing is to import the module:
安装后您要做的就是导入模块:
from loguru import logger
And you’re free to use it out of the box:
您可以随意使用它:
logger.debug("Hello, cool debugger")
The documentation is good and there are many customization options.
该文档很好,并且有许多自定义选项。
更多工具 (more-itertools)
A variety of interesting methods that could sometimes come very useful, such as peekable
:
有时可能会变得非常有用的多种有趣方法,例如peekable
:
>>> p = peekable(['a', 'b'])>>> p.peek()'a'>>> next(p)'a'
or chunked
:
或chunked
:
>>> list(chunked([1, 2, 3, 4, 5, 6], 3))[[1, 2, 3], [4, 5, 6]]
MonkeyType —静态类型注释生成器 (MonkeyType — Static type annotations generator)
monkeytype run myscript.py
This package automatically generates type annotations for you, either in a stub file or in the source code itself, by collecting runtime types. Right, Python doesn’t enforce you to use annotations — but I believe they are very important for readability of the code (and sometimes for avoiding errors), which is also why there are 2 more packages in this list that are handling type annotations :)
该程序包通过收集运行时类型,在存根文件或源代码本身中自动为您生成类型注释。 是的,Python不会强迫您使用注释-但我认为它们对于代码的可读性(有时是避免错误)非常重要,这也是为什么此列表中还有2个处理类型注释的软件包的原因: )
Pyright —静态类型检查器 (Pyright — Static type checker)
Exciting new package coming from Microsoft. The inital commit was just 17 days ago! This package is the competitor of Mypy (also on this list). To be honest, I haven’t yet had the chance to use it, but I definitely plan to. I currently use mypy as a type checker, but I’ll give this one a try!
令人兴奋的Microsoft新软件包。 最初的提交只是17天前! 该软件包是Mypy的竞争对手(也在此列表中)。 老实说,我还没有机会使用它,但是我绝对打算。 我目前将mypy用作类型检查器,但我将尝试一下!
请求-异步 -支持async
/ await
语法requests
(requests-async — support for async
/await
syntax for requests
)
This is a new package I discovered the other day on GitHub, and it seems pretty promising. We all know the requests package, that lets us easily handle HTTP requests in our code. Well, this package implements async
and await
words for these requests:
这是我前几天在GitHub上发现的一个新程序包,看起来很有希望。 我们都知道请求包,它使我们可以轻松地在代码中处理HTTP请求。 好了,这个包为这些请求实现了async
和await
字:
import requests_async as requestsresponse = await requests.get('https://example.org')print(response.status_code)print(response.text)
Pretty cool right?
很酷吧?
HTTPie —现代命令行cURL (HTTPie — Modern command line cURL)
Those of you who have used cURL before, must know it’s not that fun. Having to remember the parameters names, making sure your data is encapsulated… Well, HTTPie aims to make this much easier. Here’s one of their examples, of submitting form data:
那些以前使用过cURL的人必须知道它不是那么有趣。 必须记住参数名称,以确保您的数据被封装了……好吧,HTTPie旨在简化这一过程。 这是他们提交表单数据的示例之一:
http -f POST example.org hello=World
pipenv —更好的Python包装 (pipenv — Better packaging for Python)
When I start a new project, I always create a new virtualenv
and install some basic packages with pip
. I then need to save these packages names in a file, be it setup.py
or requirements.txt
. Those of you who have worked with npm
, know it's much simpler there. All you need to do is write npm —save
and the package name is saved in your package.json
. That's why I first created pypkgfreeze, a simple package to "freeze" the versions of your currently used pip
packages into setup.py
.
当我开始一个新项目时,我总是创建一个新的virtualenv
并使用pip
安装一些基本软件包。 然后,我需要将这些软件包的名称保存在一个文件中,无论是setup.py
还是requirements.txt
。 那些使用npm
工作过的人知道,那里的操作要简单得多。 您需要做的就是写npm —save
,包名称保存在package.json
。 这就是为什么我首先创建pypkgfreeze的原因,这是一个简单的程序包,用于将当前使用的pip
程序包的版本“冻结”到setup.py
。
Anyway, pipenv is an interesting solution that aims to merge the two worlds - They describe it best in their repo page:
无论如何,pipenv是一个有趣的解决方案,旨在合并两个世界-他们在回购页面中对其进行了最佳描述:
It automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile
as you install/uninstall packages. It also generates the ever-important Pipfile.lock
, which is used to produce deterministic builds.
它会为您的项目自动创建和管理virtualenv,并在您安装/卸载软件包时从Pipfile
添加/删除软件包。 它还会生成非常重要的Pipfile.lock
,用于生成确定性的构建。
You can try it out here.
您可以在这里尝试。
mypy —静态类型检查器 (mypy — Static type checker)
As I said before, this is the package I currently use as my standard static type checker. It helps me keep my code readable and elegant (I think).
如前所述,这是我目前用作标准静态类型检查器的软件包。 它可以帮助我保持代码的可读性和优美性(我认为)。
黑色 (black)
I have tried many Python formatters, and black
is clearly my favourite. The syntax looks neat, and the command line runs quick and can either check the files or actually edit them - very useful for CI/CD. You can even try it here!
我尝试了许多Python格式化程序,而black
显然是我的最爱。 语法看起来很整洁,命令行运行很快,可以检查文件或实际编辑它们-对于CI / CD很有用。 您甚至可以在这里尝试!
烧瓶 (flask)
Not sure if I have anything to write here that hasn’t been written before. You are probably familiar with this astonishing micro framework, and if you’re not.. you definitely should check it out.
不知道我是否有什么要写的,以前没有写过。 您可能熟悉这个令人惊讶的微型框架,如果不熟悉,那么您肯定应该检查一下。
你走之前… (Before you go…)
Thanks for reading! You can follow my GitHub account for more cool repos. I tend to star every cool thing that I see :)
谢谢阅读! 您可以关注我的GitHub帐户以获得更多很棒的存储库。 我倾向于盯着我看到的每件很酷的东西:)
If you enjoyed this article, please hold down the clap button ? to help others find it. The longer you hold it, the more claps you give!
如果您喜欢这篇文章,请按住拍手按钮? 帮助别人找到它。 握的时间越长,拍手就越多!
And do not hesitate to share your thoughts in the comments below.
并且不要在下面的评论中分享您的想法。
翻译自: https://www.freecodecamp.org/news/these-python-packages-will-help-accelerate-your-development-process-d4b3f170b1ea/
python导入外部包
相关文章:

【转修正】sql server行版本控制的隔离级别
在SQL Server标准的已提交读(READ COMMITTED)隔离级别下,一个读操作会和一个写操作相互阻塞。未提交读(READ UNCOMMITTED)虽然不会有这种阻塞,但是读操作可能会读到脏数据,这是大部分用户不能接…

【机器学习基石笔记】八、噪声和错误
噪声的来源: 1、noise in y 2、noise in x 在有noise的情况下,vc bound还会work么??? 之前,x ~ p(x) 现在 y ~ P( y | x ) 在hoeffding的部分,只要 (x, y) 联合分布满足某个分布, 结…

H5用户地址位置选择地点获取经纬度(效果图)
效果图: uni-app <template><view class"flex-v flex-c wrap"><web-view src"https://apis.map.qq.com/tools/locpicker?search1&type1&key7QKBZ-SJ2HF-7TFJS-JL5NE-E6ZD7-SWFW5&referer鏅鸿兘鍚嶇墖"></we…

学习sql注入:猜测数据库_对于SQL的热爱:为什么要学习它以及它将如何帮助您...
学习sql注入:猜测数据库I recently read a great article by the esteemed craigkerstiens describing why he feels SQL is such a valuable skill for developers. This topic really resonated with me. It lined up well with notes I’d already started sketching out fo…

C++入门经典-例6.14-通过指针连接两个字符数组
1:字符数组是一个一维数组,引用字符数组的指针为字符指针,字符指针就是指向字符型内存空间的指针变量。 char *p; char *string"www.mingri.book"; 2:实例,通过指针连接两个字符数组,代码如下&am…

创建一个没有边框的并添加自定义文字的UISegmentedControl
//个性推荐 歌单 主播电台 排行榜NSArray* promoteArray["个性推荐","歌单","主播电台","排行榜"];UISegmentedControl* promoteSgement[[UISegmentedControl alloc]initWithItems:promoteArray];promoteSgement.frameCGRectMake(0, 6…

样式集(一) 通用商品列表样式
上图: 上代码: // pages/choosePackage/choosePackage.js Page({data: {list:[1,2,3],},onLoad: function (options) {},nav_upInfo(){wx.navigateTo({url: ../upInfo/upInfo,})}, }) <!--pages/choosePackage/choosePackage.wxml--> <view c…

2019 6月编程语言_今年六月您可以开始学习650项免费的在线编程和计算机科学课程...
2019 6月编程语言Seven years ago, universities like MIT and Stanford first opened up free online courses to the public. Today, more than 900 schools around the world have created thousands of free online courses, popularly known as Massive Open Online Cours…

mybatis分页练手
最近碰到个需求,要做个透明的mybatis分页功能,描述如下:目标:搜索列表的Controller action要和原先保持一样,并且返回的json需要有分页信息,如: ResponseBody RequestMapping(value"/searc…

样式集(二) 信息填写样式模板
上图: 代码: // pages/upInfo/upInfo.js Page({data: {tipsTxt: "请填写正确的业务流水号",showTips: false,showCityList:false,city:"",cityList:["济南市","青岛市","枣庄市","东营市"…

12小时进制的时间输出的编辑代码
关于时间输出的编辑代码个人思考了很久,包括顺序,进位之类的,求完善和纠错 public class yunsuanfu {public static void main(String[] arg){double t2;int h38;int m100;int s100;if(s>60){m(s/60)m;ss%60;}if (m>60){h(m/60)h;mm%6…

c++每调用一次函数+1_每个开发人员都应该知道的一些很棒的现代C ++功能
c每调用一次函数1As a language, C has evolved a lot.作为一种语言,C 已经发展了很多。 Of course this did not happen overnight. There was a time when C lacked dynamism. It was difficult to be fond of the language.当然,这并非一overnight而…

Linux ISCSI配置
一、简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的、可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择。iSCS…

样式集(三)成功页面样式模板
上图: 代码: <!--pages/result/result.wxml--> <view><image class"scc" src"/img/scc.png"></image><view class"resuil">办理成功</view> </view> <view class"btn…

C#中Request.servervariables参数
整理一下,我在asp.net下遍历的Request.servervariables这上集合,得出的所有参数如下: : Request.ServerVariables["ALL_HTTP"] 客户端发送的http所有报头信息 返回例:HTTP_CACHE_CONTROL:max-age0 HTT…

打开浏览器的包 node_如何发布可在浏览器和Node中使用的软件包
打开浏览器的包 nodeWhen you create a package for others to use, you have to consider where your user will use your package. Will they use it in a browser-based environment (or frontend JavaScript)? Will they use it in Node (or backend JavaScript)? Or bot…

存储过程中SELECT与SET对变量赋值
Create proc insert_bookparam1char(10),param2varchar(20),param3money,param4moneyoutputwith encryption---------加密asinsert into book(编号,书名,价格)Values(param1,param2,param3)select param4sum(价格) from bookgo执行例子:declare total_price moneyex…

AngularJs $resource 高大上的数据交互
$resource 创建一个resource对象的工厂函数,可以让你安全的和RESFUL服务端进行数据交互。 需要注入 ngResource 模块。angular-resource[.min].js 默认情况下,末尾斜杠(可以引起后端服务器不期望出现的行为)将从计算后的URL中剥离…

样式集(四)搜索框样式
上图: 代码: // pages/search/search.js var textPage({data: {input_val:"",list:[]},input_p(e){this.setData({input_val:e.detail.value})},onLoad: function (options) {}, }) <view classpage_row bindtap"suo"><vi…

初步了解React Native的新组件库firstBorn
first-born is a React Native UI Component Framework, which follows the design methodology Atomic Design by Brad Frost.first-born是React Native UI组件框架,它遵循Brad Frost的设计方法Atomic Design 。 Version 1.0.0 was recently published as an npm …

less里面calc() 语法
转载 Less的好处不用说大家都知道,确实让写CSS的人不在痛苦了,最近我在Less里加入calc时确发现了有点问题,我在Less中这么写: div { width : calc(100% - 30px); } 结果Less把这个当成运算式去执行了,结果…

基于XMPP的IOS聊天客户端程序(XMPP服务器架构)
最近看了关于XMPP的框架,以文本聊天为例,需要发送的消息为: <message type"chat" from"kangserver.com" to"testserver.com"> <body>helloWord</body> </message> …

小程序云开发,判断数据库表的两个字段匹配 云开发数据库匹配之 and 和 or 的配合使用
云开发数据库匹配之 and 和 or 的配合使用 代码: // 获取成员消息onMsg2() {let that thiswx.cloud.init({env: gezi-ofhmx})const DB wx.cloud.database()const _ DB.command;var aa "1"var bb "2"DB.collection(message_logging).where…

react引入多个图片_重新引入React:v16之后的每个React更新都已揭开神秘面纱。
react引入多个图片In this article (and accompanying book), unlike any you may have come across before, I will deliver funny, unfeigned and dead serious comic strips about every React update since v16. It’ll be hilarious, either intentionally or unintention…

75. Find Peak Element 【medium】
75. Find Peak Element 【medium】 There is an integer array which has the following features: The numbers in adjacent positions are different.A[0] < A[1] && A[A.length - 2] > A[A.length - 1].We define a position P is a peek if: A[P] > A[P-1…

云开发地图标记导航 云开发一次性取所有数据
地图取 elx 表格的经纬度数据,存到云开发数据库里面,然后标记在地图上,点击地图的标记可以实现路线规划,导航,拨打电话。 elx数据格式如下: 云开发的数据库不能直接导入elx,所以需要转换为csv文…

未能加载文件或程序集“Report.Basic”或它的某一个依赖项。试图加载格式不正确的程序...
出现问题如下: 解决办法: 这是由于没有开启32位程序兼容模式 具体操作如下:找到对应的程序池--------高级设置-------修改“启用32位应用程序”状态修改为true 转载于:https://www.cnblogs.com/OliverQin/p/5018575.html

flutter开发小程序_为什么我认为Flutter是移动应用程序开发的未来
flutter开发小程序I dabbled a bit in Android and iOS development quite a few years back using Java and Objective-C. After spending about a month working with both of them, I decided to move on. I just couldn’t get into it.几年前,我使用Java和Obje…

小程序获取图片的宽高
代码: imgInfo(url){wx.getImageInfo({src: url,success (res) {console.log(res.width)console.log(res.height)return {width:res.width,height:res.height}}})},

凯撒密码、GDP格式化输出、99乘法表
1.恺撒密码的编码 plaincode input(明文:)print(密文:,end)for i in plaincode: print(chr(ord(i)3),end) 2.国家名称 GDP总量(人民币亿元) 中国 ¥765873.4375澳大利亚 ¥ 78312.4375(国家名称左…