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

python去除空格和换行符的实现方法(推荐)

一、去除空格strip()"   xyz   ".strip()            # returns "xyz"  "   xyz   ".lstrip()           # returns "xyz   "  "   xyz   ".rstrip()           # returns "   xyz"  "  x y z  ".replace(' ', '')   #...

View Article


python去掉行尾的换行符方法

如下所示:mystring.strip().replace(' ', '').replace('\n', '').replace('\t', '').replace('\r', '').strip()以上就是小编为大家带来的python去掉行尾的换行符方法全部内容了,希望大家多多支持脚本之家~

View Article


Image may be NSFW.
Clik here to view.

Java和Python―哪个更有效率?

Java和python―哪个更有效率? 一点号智能社3小时前 你认为Python和Java哪个更有创意?受诸多因素影响,Python的确更有效率一些,Java是静态类型的,而Python属于动态,在许多编程语言里,关于动态类型和静态类型这个话题有颇多争议,下面,我们通过图表清晰直观地区别这两种编程语言。 php?url=0FS1gSKpBm" alt="Java和Python―哪个更有效率?"...

View Article

Fix Ctrl-P not indexing all your files

I started using NeoVim a year ago and I siwtch between it and Visual Studio Code quite often. I use NeoVim mostly when I do text editing. I use it almost exclusively when writing blog articles, notes...

View Article

Image may be NSFW.
Clik here to view.

Build a CRUD Web App With Python and Flask Part Three

This is the last part of a three-part tutorial to build an employee management web app, named Project Dream Team. InPart Two of the tutorial, we built out the CRUD functionality of the app. We created...

View Article


Image may be NSFW.
Clik here to view.

Customizing your Navigation Drawer in Kivy & KivyMD

Kivy is an open source, cross-platform python framework for the development of applications that makes use of innovative, multi-touch user interfaces. KivyMD is a collection of Material Design...

View Article

python数据持久存储:pickle模块的基本使用

python的pickle模块实现了基本的数据序列和反序列化。通过pickle模块的序列化操作我们能够将程序中运行的对象信息保存到文件中去,永久存储;通过pickle模块的反序列化操作,我们能够从文件中创建上一次程序保存的对象。 基本接口: pickle.dump(obj, file, [,protocol]) 注解:将对象obj保存到文件file中去。...

View Article

Image may be NSFW.
Clik here to view.

【Python核心编程】入门的微妙关系

本帖最后由 MAX丶 于 2017-1-6 07:43 编辑 今天我们和我从零开始学习python表达关。 使用compile()函数编译正则表达式。 对于一些特别的正则表达式编译可选的标记可能参数的形式给出,这些标记允许不区分大小写的匹配,使用系统的本地化设置来匹配字母数字,等等也可以参考官方文档中查询关于这些标记 [Python] 纯文本查看 复制代码...

View Article


Image may be NSFW.
Clik here to view.

Python NLTK学习7(对中文昵称进行性别分类)

作者:刘杰 本系列博客为学习《用python进行自然语言处理》一书的学习笔记。 引言 分类就是对事物进行归类,举个栗子:男人站左边,女人站右边,人妖站中间。文本分类就是对文本进行归类,举个栗子:垃圾邮件过滤。 那么程序是如何分辨出一个邮件是垃圾邮件还是普通邮件的呢?...

View Article


Precision Handling in Python

python in its definition allows to handle precision of floating point numbers in several ways using different functions. Most of them are defined under the “ math ” module. Some of the most used...

View Article

Force Python version in Vim

Vim can be compiled with python support. Vim can be compiled with both Python 2 and Python 3 support. At the same time. But not really. Vim can have both of them, but use only one at a time. If you...

View Article

struct module in Python

This module performs conversions between python values and C structs represented as Python bytes objects. Format strings are the mechanism used to specify the expected layout when packing and unpacking...

View Article

Image may be NSFW.
Clik here to view.

妙用Hook来研究Python的Import机制

这两天周末在家学习python,我发现我们平常接触最多的也就是import这条语句,这两天在编写一些程序的时候恰恰需要import hook去完成一些操作,借着这个周末在家闲着没事儿通过import hook这个命令,把Python的import机制了解了一下。 0x00 Import机制概述 从名字上可以推断出,import...

View Article


Image may be NSFW.
Clik here to view.

Python获取Linux或Windows系统的基本信息

前段时间写了一篇博文名为《 利用python脚本获取windows和linux的系统版本信息 》,本篇博文利用这篇文章中的知识提供一个增强版本的获取信息的Python脚本。执行后,看起来就像登录Ubuntu Linux系统时提示的motd信息一样,可以看到: 系统的类型、发行版本(具体信息)、内核版本等 当前系统的时间、时区 系统每一个CPU核心的负载和CPU整体负载 进程数量...

View Article

Image may be NSFW.
Clik here to view.

python中函数与函数之间的调用,总是晕菜,整理如下,有不对或者补充的请提出来~

1.python函数基础 函数名: fun 函数体:1~3行 返回值:2 调用函数:fun() ,只有见到这个括号(),程序会根据函数名从内存中找到函数体,然后执行它。 2.函数的执行顺序 下面的fun将上面的fun覆盖掉了,因此,在Python中代码的放置位置是有要求的,不能随意摆放,函数体要放在被调用的语句之前。 3.函数的调用 第一种情况: x(f), 注意 :x(f)中的f没有加括号(),即...

View Article


Python 为什么list不能作为字典的key?

很多python初学者经常会有这样的疑问,为什么Python有tuple(元组)和list(列表)两种类型?为什么tuple可以作为字典的key,list不可以?要理解这个问题,首先要明白python的字典工作原理。 Python的字典是如何工作的 在Python中,字典也就是一个个的“映射”,将key映射到value: # 对一个特定的key可以得到一个value value = d[key]...

View Article

Image may be NSFW.
Clik here to view.

Python ― lzma压缩

python ― lzma压缩 一点号Python热爱者昨天 一、异常 lzma这个包中只提供了一个异常:lzma.LZMAError。这个异常只有如下情况会抛出: 压缩或解压时发生错误 初始化压缩器与解压器的状态时发生错误 二、读写压缩文件 1、接口1 lzma中提供了一个借口,专门用来访问压缩文件:lzma.open(filename, mode="rb")...

View Article


Image may be NSFW.
Clik here to view.

PYTHON黑帽编程 4.1 SNIFFER(嗅探器)之数据捕获--补充

荒废了一个多月了,重新捡起来,手生了不少。发现在《4.1下》的文章里没有 提到pcap库,实在是不应该。 在网络数据分析的工具中,tcpdump绝对是大名鼎鼎,tcpdump底层是libpcap库,由C语言编写。 Pcapy模块则是基于libpcap的python接口。pcapy在github上的项目地址为: https://github.com/CoreSecurity/pcapy。...

View Article

python之路 - 基础3

1.字符串处理 1 name = "my name is jiachen" 2 #首字母大写 3 print (name.capitalize()) 4 #统计字母出现次数 5 print (name.count('a')) 6 #居中打印 7 print (name.center(50,'-')) 8 #字符串装换成bytes类型 9 print (name.encode('utf-8')) 10...

View Article

Pytest One Solution for Unit, Functional and Acceptance Tests

python: A tester’s choice Python is a general purpose, dynamic and flexible language, hence a lot of applications are being developed using Python. From a tester’s perspective, it has readily available...

View Article
Browsing all 9596 articles
Browse latest View live