![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
文章平均质量分 69
unknown-null
这个作者很懒,什么都没留下…
展开
-
使用python进行pdf文件分割
import osfrom pyPdf import PdfFileWriter, PdfFileReaderdef split(pdf_file, delta, output_dir): if not os.path.exists(output_dir): os.makedirs(output_dir) if not os.path.exists(pdf_file): return print('----------参数信息---------.原创 2021-03-05 15:31:04 · 539 阅读 · 0 评论 -
【Python基础教程】第5章
5.1 print和import的更多特性>>> #5.1.1 使用逗号输出>>> print 'Age:',42Age: 42>>> #注:print的参数并不能构成一个元组(还记得创建元组时必须要有逗号吗?在第2章2.4节)>>> print 1,2,31 2 3>>> print (1,2,3)(1, 2, 3)>>> #如果在结尾处加上逗号,接下来的语句会与前一条语句在原创 2015-01-21 21:25:42 · 423 阅读 · 0 评论 -
【Python基础教程】第10章 模块
10.3 标准库10.3.3 fileinput#给脚本的每一行后面添加行号import fileinput for line in fileinput.input(inplace = True): line = line.rstrip原创 2015-02-09 22:56:27 · 572 阅读 · 0 评论 -
【Python基础教程】第2章 列表和元组-2.2通用序列操作
2.2 通用序列操作(索引,分片,加,乘,成员资格)(计算序列长度、最大元素、最小元素)2.2.1 索引>>> #2.2.1 索引>>> greeting = 'Hello'>>> greeting[0]'H'>>> greeting[-1]#最后一个元素的位置编号是-1'o'>>> 'Hello'[1]'e'>>> fourth = raw_input('原创 2015-01-19 13:24:08 · 533 阅读 · 0 评论 -
【Python基础教程】第2章 列表和元组-2.4元组:不可变序列
序列中Python中的一种数据结构,它包含的元素都进行了编号。典型的序列包括列表、字符串和元组。其中,列表是可变的(可以进行修改),而元组和字符串是不可变的(一旦创建就是固定的)为何需要元组?1.元组可以在映射中当作键使用——而列表不行。(因为元组是不可变的,故能做键使用,而列表是可变的。)2.元组作为很多内建函数和方法的返回值存在。2.4.0 创建元组原创 2015-01-19 15:12:43 · 1423 阅读 · 0 评论 -
【Python基础教程】第3章 字符串
所有标准的序列操作(索引,分片,乘法,判断成员资格,求长度,最大值,最小值)对字符串都是同样适用的。3.1 字符串是不可变的在Python中,字符串和元组一样,都是不可变的,即一经创建就不可更改它。>>> #以下的分片赋值是不合法的>>> website = 'http://www.python.org'>>> website[-3:] = 'com'Traceback (mo原创 2015-01-20 20:14:32 · 1245 阅读 · 0 评论 -
【Python基础教程】第4章 字典
4.2 初识字典>>> #4.2 初识字典>>> phone = {'Alice': '2341','Beth': '9102','Cecil': '3258'}4.2.1 dict函数>>> #4.2.1 dict函数>>> #dict函数通过(键,值)序列对创建字典>>> items = [('name', 'Gumby'), ('age', 42)]>>> d = di原创 2015-01-20 21:50:15 · 1123 阅读 · 0 评论 -
【Python基础教程】第6章 函数
6.3 函数初识>>> ##6.3 创建函数>>> def hello(name): return 'Hello, ' + name + '!'>>> #6.3.1 记录函数:为函数添加文档字符串>>> def square(x): 'Calculates the square of the number x.' return x*x>>> square.__doc__'C原创 2015-01-23 23:32:23 · 413 阅读 · 0 评论 -
【Python基础教程】第11章 文件
11.2 文件常用方法打开文件open(name[, mode[, buffering]])name:文件名,此参数是必须的。mode:打开文件的模式,此参数是可选的,默认打开的文件为读模式。buffering:缓冲区。如果参数为0(或False),I/O是无缓冲的。(所有的读写操作直接针对硬盘)如果参数为1(或True),I/O是有缓冲的。(读写操作在内存中,原创 2015-01-26 23:12:04 · 417 阅读 · 0 评论 -
【Python基础教程】第7章 类
#7.2.5 继承class Filter: def init(self): self.blocked = []; def filter(self, sequence): return [x for x in sequence if x not in self.blocked]class SPAMFilter(Filter):#SPAMFilt原创 2015-01-26 12:29:32 · 376 阅读 · 0 评论 -
【Python基础教程】第8章 异常
1.自定义异常:继承Exception#1.自定义异常类#方法:从Exception类继承class SomeCustomException(Exception):pass2.处理异常#(1)捕捉异常:try/excepttry: x = input('Enter the first number:') y = input('Enter the secon原创 2015-01-26 12:30:15 · 436 阅读 · 0 评论 -
【Python基础教程】第2章 列表和元组-2.3 列表
列表是可变的,意味着在列表创建之后可以改变列表的内容。2.3.1 list函数>>> #2.3.1 list函数>>> #根据字符串创建列表>>> listA = list('Hello')>>> listA['H', 'e', 'l', 'l', 'o']>>> #将字符组成的列表转换为字符串>>> strA = ''.join(listA)>>> strA'Hello'原创 2015-01-19 14:43:23 · 512 阅读 · 0 评论