Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Browsing all 9596 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

在python 中如何将 list 转化成 dictionary 丨数析学院

问题1:如何将一个list转化成一个dictionary? 问题描述:比如在python中我有一个如下的list,其中奇数位置对应字典的key,偶数位置为相应的value 解决方案: 1.利用zip函数实现 2.利用循环来实现 3.利用 enumerate 函数生成index来实现 问题2 我们如何将两个list 转化成一个dictionary? 问题描述:假设你有两个list...

View Article


Glyph Lefkowitz

Remember that thing I said in my pycon talk about native packaging being the main thing to worry about, and single-file binaries being at best a stepping stone to that and at worst a bit of a red...

View Article


Image may be NSFW.
Clik here to view.

利用 Python 进行数据分析(十三)pandas:数据重塑/轴向旋转

重塑定义 重塑指的是将数据重新排列,也叫轴向旋转。 DataFrame提供了两个方法: stack: 将数据的列“旋转”为行。 unstack:将数据的行“旋转”为列。 例如: 处理堆叠格式 堆叠格式也叫长格式,一般关系型数据库存储时间序列的数据会采用此种格式,例如:...

View Article

Image may be NSFW.
Clik here to view.

Python面试题 ―― 计算列表中出现最多次的字符

给你一个其中包含不同的英文字母和标点符号的文本,你要找到其中出现最多的字母,返回的字母必须是小写形式, 当检查最想要的字母时,不区分大小写,所以在你的搜索中 "A" == "a"。 请确保你不计算标点符号,数字和空格,只计算字母。 如果你找到 两个或两个以上的具有相同的频率的字母, 返回那个先出现在字母表中的字母。 例如 -- “one”包含“o”,“n”,“e”每个字母一次,因此我们选择“e”。...

View Article

Image may be NSFW.
Clik here to view.

asyncpg:高效的基于 Python/asyncio 的 PostgreSQL 客户端库

asyncpg -- A fast PostgreSQL Database Client Library for python/asyncio asyncpgis a database interface library designed specifically for PostgreSQL and Python/asyncio. asyncpg is an efficient, clean...

View Article


The One Python Library Everyone Needs

Do you write programs in python? You should be using attrs . Why, you ask? Don’t ask. Just use it. Okay, fine. Let me back up. I love Python; it’s been my primary programming language for 10+ years...

View Article

[原]Python使用Bottle来提供一个简单的web服务

python使用Bottle来提供一个简单的web服务 介绍 今天有个不正经的需求,就是要快速做一个restful api的性能测试,要求测试在海量作业数据的情况下客户端分页获取所有作业的性能。因为只是一个小的的测试工作,所以就想到了Bottle框架作为Web服务器,这里就简单说说怎样使用Bottle框架。 安装 pip install bottle 启动服务...

View Article

Volume 13: Eagerly Evaluated Questions, with Joseph Jevnik

Greetings, friends! Last week our engagement took a bit of a nose dive, with opens and clicks dropping a bunch. This is surprising since metrics for hifi have always been well above industry average,...

View Article


用 Python 和 Asyncio 编写多人在线游戏(一)

之前 pythonTG 翻译组分享过一篇 Pygame 的入门教程,教的是单机游戏开发。今天和大家分享如何编写一个多人在线游戏,此教程共分为三部分,今天是第一篇,为大致概述。有兴趣的朋友请继续关注后续文章。 本文作者为 Kyrylo Subbotin,是一家 IT 咨询公司的 Python 工程师。本文译者为 sleepyjoker,由编程派作者 EarlGrey 校对。...

View Article


Image may be NSFW.
Clik here to view.

[译] 用 Python 和 Asyncio 编写多人在线游戏

[译] 用 python 和 Asyncio 编写多人在线游戏 5小时前来源:开发者头条 php?url=0EB61ycFBZ" alt="[译] 用 Python 和 Asyncio 编写多人在线游戏" />之前 PythonTG 翻译组分享过一篇 Pygame...

View Article

Image may be NSFW.
Clik here to view.

Python Spider

一、网络爬虫...

View Article

Python 入门之旅

昨天写了一篇文章叫做 《十分钟入门 python》,里面仅仅介绍了 Python 的一些基础属性,想要利用那么点知识有所作为的话,怕是有点难度。所以今天再来详细介绍一下 Python 的语法知识。 1 . 数与字符串 Python 中数有 5 中类型, 分别为 int(有符号整数型) , long(长整型) , float(浮点型) , bool (布尔型) , complex (复数型) a =...

View Article

yield python

3. (译)python关键字yield的解释(stackoverflow) 译者: hit9 原文: http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained 译者注: 这是stackoverflow上一个很热的帖子,这里是投票最高的一个答案 Contents...

View Article


Image may be NSFW.
Clik here to view.

深浅拷贝 python

原文:http://www.jb51.net/article/15714.htm 1. copy.copy 浅拷贝 只拷贝父对象,不会拷贝对象的内部的子对象。 2. copy.deepcopy 深拷贝 拷贝对象及其子对象 一个很好的例子: importcopy a=[1,2,3,4,['a','b']]#原始对象 b=a#赋值,传对象的引用 c=copy.copy(a)#对象拷贝,浅拷贝...

View Article

Image may be NSFW.
Clik here to view.

Python自动化运维之11、面向对象基础

一、简介 面向对象编程是一种编程方式,使用 “类” 和 “对象” 来实现,所以,面向对象编程其实就是对 “类” 和 “对象” 的使用。类就是一个模板,模板里可以包含多个方法(函数),方法里实现各种各样的功能,,对象则是根据模板创建的实例,通过实例,对象可以执行类中的方法,每个对象都拥有相同的方法,但各自的数据可能不同。 二、类、对象和方法 在python中,定义类是通过 class 关键字,...

View Article


Tab (YC W15) Is Hiring a Backpacking Back Ender (travel, Fintech, Python,...

Tab is a young startup that mixes travel & fintech, backed by Y Combinator. Tab powers bookings and payments for tourist businesses (like hostels, dive schools and surf lodges) in emerging...

View Article

Andrew Dalke: Faster parity calulation

[previous | next ] /home/ writings / diary / archive / 2016 / 08 /15/fragment_parity_calculation Faster parity calulation In the previous essay I needed determine the parity of a permutation. I used a...

View Article


What's new with neutron-lib 0.3.0

Forward OpenStack neutron-lib version 0.3.0 was recently released to PyPI and contains a number of updates to API validators , constants and hacking checks . The complete list of public API changes are...

View Article

Image may be NSFW.
Clik here to view.

PyDev of the Week: Harry Percival

This week we welcome Harry Percival ( @hjwp ) as our PyDev of the Week! Harry is the author of Test-Driven Development with python . You can visit his website to learn more about the book and even...

View Article

dis ― Python Bytecode Disassembler ― PyMOTW 3

The dis module includes functions for working with python bytecode by “disassembling” it into a more human-readable form. Reviewing the bytecodes being executed by the interpreter is a good way to...

View Article
Browsing all 9596 articles
Browse latest View live