Python学习记录

Python的创始人为
吉多·范罗苏姆
(Guido van Rossum)
Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/),是一种面向对象、直译式的电脑程序语言。它包含了一组功能完备的标准库,能够轻松完成很多常见的任务。它的语法简单,与其它大多数程序设计语言使用大括号不一样,它使用缩进来定义语句块。
与Scheme、Ruby、Perl、Tcl等动态语言一样,Python具备垃圾回收功能,能够自动管理内存使用。它经常被当作脚本语言用于处理系统管理任务和网络程序编写,然而它也非常适合完成各种高级任务。Python虚拟机本身几乎可以在所有的操作系统中运行。使用一些诸如py2exe、PyPy、PyInstaller之类的工具可以将Python源代码转换成可以脱离Python解释器运行的程序。
Python的官方解释器是CPython,该解释器用C语言编写,是一个由社区驱动的自由软件,目前由Python软件基金会管理。
Python支持命令式程序设计、面向对象程序设计、函数式编程、面向侧面的程序设计、泛型编程多种编程范式。
python 读写csv文件示例
2021年01月31日
csv在python的作用主要有以下几个方面:作为数据交换,由于使用文本很难写入list,同时处理的时候也都是string类型的数据,而csv写入的是list的数据,同时也可以返回list数据,所以在python中文本作为数据交换的方式,并没有csv方便;csv在python中得到了很好的支持,可以参考下面引用。基于以上原因,在python中csv应该很好的被利用起来。写csv文件的方式:def ...
python 验证IP地址
2021年01月23日
如果您使用Python3,则可以使用ipaddress模块。下面是示例:>>> import ipaddress >>> ipv6 = "2001:0db8:0a0b:12f0:0000:0000:0000:0001" >>> ipv4 = "192.168.2.10" >>> ipv4invalid = "266.255.9.10" >>> str = "Tay Tay" >>...
python字符串相关操作总结
2021年01月20日
最近在python程序中,遇到使用subprocess读取系统命令相关操作,涉及到大量的字符串操作,对python字符串操作进行总结。bytes装换成str:result.stdout.decode('utf-8')result.stdout是bytes数据类型,转成str类型。字符串查找:get_time_result.index('time')python 的index方法是在字符串里查找子串...
TypeError: can only concatenate str (not "int") to str
2021年01月19日
在调试程序的时候出现如下错误:TypeError: can only concatenate str (not "int") to str出现问题的原因:只能将str(而不是“ int”)连接到str,具体错误代码如下:for item in range(int(start_ip), int(end_ip + 1)):start_ip和end_ip都是str数据类型,问题出现在:end_ip+1,...
python logging.warn 和 logging.warning 的区别
2021年01月19日
logging.warn从Python 3.3开始已弃用,您应该使用logging.warning。在此之前的Python 3.3,logging.warn并且logging.warning是相同的功能。参考资料:1、What's the difference between logging.warn and logging.warning in Python?
python range
2021年01月19日
python range语法:range(start, stop, step)start 开始数字end 结束数字,不包括结束的数step 步数,默认为1下面是代码示例:x = range(3, 6) for n in x: print(n)结果:3 4 5
Specify the 'foreign_keys' argument
2021年01月14日
在处理SQLAlchemy模型的时候,出现了如下错误:sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class CoCode->c...
appears to be a non-schema 'sqlalchemy.sql.colu mn()' object
2021年01月11日
在使用SQLAlchemy件库的过程中,出现如下警告:SAWarning: Attribute 'continent_name_en' on class <class 'app.models.IPCrawlerContinent'> appears to be a non-schema 'sqlalchemy.sql.column()' object; this won't be part of ...