Python
胶水语言的魅力无可阻挡
小橘猫cate
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python笔记——with as 语句
with as 语句原创 2022-06-19 20:52:14 · 233 阅读 · 0 评论 -
Python笔记——PIL库
PIL库(Python Image Library)原创 2022-06-19 20:47:22 · 552 阅读 · 0 评论 -
Python笔记——打开Python工程
打开Python工程原创 2022-06-19 20:45:47 · 1007 阅读 · 0 评论 -
Python笔记——DeprecationWarning
DeprecationWarning原创 2022-06-19 20:38:45 · 2414 阅读 · 0 评论 -
Python笔记——PermissionError
PermissionError原创 2022-06-19 20:35:12 · 464 阅读 · 0 评论 -
Python编程——异常处理
Python编程——异常处理1、异常2、常见的异常IOErrorNameErrorTypeErrorSyntaxErrorAttributeErrorImportErrorIndentationErrorValueErrorKeyErrorKeyboardInterrupt原创 2022-02-06 15:37:23 · 615 阅读 · 0 评论 -
Python编程——目录
Python编程——目录1、os.mkdir()2、os.makedirs()3、os.rmdir()4、os.removedirs()5、os.listdir() 查看目录查看当前目录查看根目录6、os.getcwd()获取当前目录的绝对路径,7、os.chdir()切换目录8、目录遍历给出一个绝对路径,输出该绝对路径下的所有文件,每个文件也以绝对路径的形式列出,原创 2022-02-04 20:10:31 · 564 阅读 · 0 评论 -
python编程——文件
python编程——文件1、open或者file读写文件2、打开模式,w写文件方式打开,如果没有就创建文件,如果有此文件则清空文件内容w 模式打开文件时会先清空文件内容,3、r+ 方式打开文件,文件指针停留在文件开头4、FileObject.readline()每次读取文件的一行,5、FileObject.readlines()读多行数据,返回一个列表,原创 2022-02-04 17:24:24 · 743 阅读 · 0 评论 -
Python编程——浅拷贝与深拷贝
Python编程——浅拷贝与深拷贝1、a和b是同一地址空间的标签,对象b是对象a的引用2、浅拷贝,如下c是对父对象a的浅拷贝,对象不一样,但里面的数据一样但’a’是一样的,3、深拷贝,对对象资源的拷贝,如下d是对父对象a的深拷贝,对象不一样,里面的数据也不一样...原创 2022-02-04 14:52:25 · 365 阅读 · 0 评论 -
Python编程——一个小爬虫
Python编程——一个小爬虫1、获取html2、获取图片3、下载图片原创 2022-02-04 14:03:43 · 236 阅读 · 0 评论 -
Python编程——正则表达式
Python编程——正则表达式正则表达式通过re模块实现。并非所有字符串处理都能用正则表达式完成。元字符:. ^ $ * + ? {} [] \ | ()1、[] 常用来指定一个字符集,注意:元字符在字符集中不起作用Eg1:Eg2:Eg3:取反2、尖角号:^, 匹配行首,caret (英语发音:/ˈkærət/)3、$ 匹配行尾4、规则中的尖角号^是元字符,表示匹配行首,\用于取消元字符...原创 2022-02-03 21:16:44 · 204 阅读 · 0 评论 -
Python编程——包和模块
Python编程——包和模块模块是Python组织代码的基本方式。一个Python脚本可以单独运行,也可以导入另一个脚本中运行,当脚本被导入运行时,我们称其为模块(module)。1、查看Python包安装的详细路径2、模块调用时,被调用模块必须以.py后缀结尾解决办法:3、如何控制被调用模块的函数是否执行?内置变量 __name__ 的作用:判断py文件直接被运行,还是被引入其他程序中。当你直接执行一段脚本的时候,这段脚本原创 2022-02-03 17:06:52 · 162 阅读 · 0 评论 -
Python编程——内置函数
Python编程——内置函数1、常用函数abs()max()min()len()divmod() 商模函数q退出>>> divmod(3,2)(1, 1)>>>pow() 幂函数>>> pow(2,3)8>>>round() 返回浮点数>>> round(5)5.0>>>callable原创 2022-02-02 23:28:56 · 287 阅读 · 0 评论 -
Python编程——字典实现Switch语句功能
Python编程——字典实现Switch语句功能1、字典实现Switch语句功能[root@cate my_python]# python test_switch0.5from __future__ import division导入python未来支持的语言特征division(精确除法),当我们没有在程序中导入该特征时,"/"操作符执行的是截断除法(Truncating Division),当我们导入精确除法之后,"/"执行的是精确除法。...原创 2022-02-02 17:47:53 · 553 阅读 · 0 评论 -
Python编程——函数
Python编程——函数函数的作用:降低编程难度,将大问题分解为小问题。实现代码重用,提高工作效率。1、传值调用Eg1:[root@cate my_python]# python test_funcplease input the value of s:hello worldthe value of s is: hello world[root@cate my_python]#Eg2:[root@cate my_python]# python原创 2022-02-02 17:07:58 · 547 阅读 · 0 评论 -
Python编程——流程控制之while语句
Python编程——流程控制之while语句1、while循环退出[root@cate my_python]# python test_whilehelloplease input the value of x,q for quit:hellohelloplease input the value of x,q for quit:ahelloplease input the value of x,q for quit:q[root@cate my_python]#原创 2022-02-02 14:13:32 · 247 阅读 · 0 评论 -
Python编程——流程控制之遍历和循环
Python编程——流程控制之遍历和循环1、通过序列值进行遍历[root@cate my_python]# vim test_travel[root@cate my_python]# python test_travelhello2、通过索引进行遍历[root@cate my_python]# python test_travelhello3、列表的遍历和元组的遍历[root@cate my_python]# pyt原创 2022-02-02 14:12:10 · 278 阅读 · 0 评论 -
Python编程——流程控制之for语句
Python编程——流程控制之for语句1、for语句注意:代码块缩进原则Eg1:当序列是字符串时[root@cate my_python]# vim test_for[root@cate my_python]# python test_forhello worldhello worldhello worldhello worldeg2:当序列是列表时,[root@cate my_python]# python test_for0 hel.原创 2022-02-01 23:03:31 · 150 阅读 · 0 评论 -
Python编程——流程控制之if语句
Python编程——流程控制之if语句1、if语句以四个空格作为缩进[root@cate my_python]# vim test_if[root@cate my_python]# python test_ifOk2、if-else语句[root@cate my_python]# python test_ifnot ok3、if-elif-else 语句[root@cate my_python]# python test_ifplease原创 2022-02-01 23:01:42 · 232 阅读 · 0 评论 -
Python编程——数据类型
Python编程——数据类型数字、字符串、序列:列表[]、元组()、字典{键:值}1、整型[root@cate my_python]# pythonPython 2.7.5 (default, Apr 11 2018, 07:36:10)[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2Type "help", "copyright", "credits" or "license" for more informatio原创 2022-02-01 22:59:08 · 238 阅读 · 0 评论 -
Python编程——变量、运算符与表达式
Python编程——变量、运算符与表达式1、变量的定义和使用>>> a=5>>> b=3>>> a+b82、变量的地址空间以数据为基准Eg1:>>> a=123>>>>>> id(a)12262720>>>>>> a=456>>>>>> id(a)130121原创 2022-02-01 22:56:54 · 338 阅读 · 0 评论 -
Python编程——编程环境
Python编程——编程环境大多数Linux发行版都默认安装了Python环境1、打开CentOS7.5终端,启动Python交互模式[root@cate ~]# pythonPython 2.7.5 (default, Apr 11 2018, 07:36:10)[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2Type "help", "copyright", "credits" or "license" for more原创 2022-02-01 22:53:36 · 729 阅读 · 0 评论
分享