python视频学习
python视频学习,主要针对中谷教育python系列视频教程进行学习和实践。在基于Linux系统Ubuntu版本,进行有关python脚本语言的实践学习。
Digital2Slave
图像处理算法,机器学习,深度学习及其应用。
展开
-
python OS-目录遍历-异常处理
1.---OS操作---linux下创建多级目录:mkdir -p a/b/c/d[user1@localhost Desktop]$ cd ~[user1@localhost ~]$ lsa2.t Desktop Downloads Music Pictures replace.py test.txta.t Documents原创 2013-12-10 16:46:40 · 3149 阅读 · 0 评论 -
python 文件替换
#/usr/bin/python#coding:utf8#文件内容替换练习#1.把a.t中的hello替换为csvt,并保存到文件a2.t中。#2.把a.t中的hello替换为csvt,并保存到原文件中去。#problem1:fp1 = file("a.t","r")fp2 = file("a2.t","w")for s in fp1.readlines(): fp2.w原创 2013-12-10 16:44:07 · 1788 阅读 · 0 评论 -
python 文件查找
#/usr/bin/python#coding:utf8#problem1:find file#cat a.t#hello world#hello hello world#统计文件a.t中hello的个数import refp = file("a.t","r")#count = 0for s in fp.readlines(): li = re.findall("hel原创 2013-12-10 16:42:45 · 1432 阅读 · 0 评论 -
python 文件对象方法
[user1@localhost ~]$ pythonPython 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>原创 2013-12-10 16:38:31 · 1795 阅读 · 0 评论 -
python 文件读写
[user1@localhost ~]$ lsDesktop Downloads new.txt Pictures Templates test.txt~Documents Music new.txt~ Public test.txt Videos[user1@localhost ~]$ pythonPython 2.6.6 (r266:84292,原创 2013-12-10 16:37:10 · 1480 阅读 · 0 评论 -
python 文件打开和关闭
[user1@localhost ~]$ lsDesktop Downloads Pictures Templates test.txt~Documents Music Public test.txt Videos[user1@localhost ~]$ cat test.txtwww.cvst.neti am a python leaner.hell原创 2013-12-10 16:36:13 · 3982 阅读 · 0 评论 -
python 浅拷贝和深拷贝
1.所谓浅拷贝只是对引用的拷贝(只拷贝父对象)2.所谓深拷贝就是对对象的资源进行拷贝user1@ubuntu:~$ pythonPython 2.7.3 (default, Sep 26 2013, 20:03:06) [GCC 4.6.3] on linux2Type "help", "copyright", "credits" or "license" for m原创 2013-12-08 15:43:11 · 1088 阅读 · 0 评论 -
python 正则表达式之二
使用正则表达式 --re模块提供了一个正则表达式引擎的接口,可以让你讲REstring编译成对象并用它们来进行匹配 --编译正则表达式 #!python >>>import re >>>p = re.compile('ab*') >>>print p --re.compile()也接受可选的标志参数原创 2013-12-08 15:39:05 · 1380 阅读 · 0 评论 -
python 正则表达式之一
正则表达式(或RE)是一个小型高度专业化的编程语言,它内嵌于python中,并通过re模块实现。--可以为想要匹配的相应字符串集指定规则--该字符串集可能包含英文语句、e-mail地址、命令或者任何你想搞定的信息--可以问诸如“这个字符串匹配该模式么?”或“在这个字符串中是否有部分匹配该模式?”--你也可以使用RE以各种方式修改或者切割字符串1)正则表达式模块被编译成一原创 2013-12-08 15:35:40 · 1236 阅读 · 0 评论 -
python 模块和包
1.模块 模块是python组织代码的基本方式。python的脚本都是以.py为扩展名保存的文本文件。一个脚本可以单独运行,也可以导入另一个脚本中运行。当脚本被导入运行时,我们将其称为模块。 模块名与脚本的文件名相同!例如我们编写一个cal.py的脚本,则可以在另外一个脚本中用import cal语句来导入它进行相关运算操作。user1@ubuntu:~$ cd csvtpy/原创 2013-12-02 18:42:21 · 3159 阅读 · 0 评论 -
python 内建函数
abs(): 绝对值 max(): 最大值 min(): 最小值 len(): 序列(字符串、元组和列表)的长度 divmod(): 两个数的商和余数>>> divmod(5,2)(2, 1)>>> divmod(2,5)(0, 2) pow(): 幂次操作 round(): 转换为有一定精度的小数 callable():原创 2013-12-02 18:37:00 · 1229 阅读 · 0 评论 -
python switch函数
python并没有提供switch语句!python可以通过字典实现switch语句的功能。 1)首先,定义一个字典; 2)其次,调用字典的get()获取相应的表达式。#!/usr/bin/python#coding:utf8from __future__ import division#使除非操作自动识别小数结果def jia(x,y): return x+yd原创 2013-12-02 18:29:42 · 4590 阅读 · 0 评论 -
python lambda函数
lambda:匿名函数lambda函数是一种快速定义单行的最小函数,从Lisp借用而来,可以用在任何函数的地方。lambd语句中,冒号前是参数,可以有多个以逗号分开的参数;冒号后面是返回值。lambda语句构建的其实是一个函数对象.>>> g = lambda x,y:x+y>>> g at 0x23556e0>reduce为逐次操作list里的每一项,接收的参数为两个,最原创 2013-12-02 18:28:06 · 1209 阅读 · 0 评论 -
python 函数多实参处理
向函数传元组和字典:f(*t) 和 f(**d) 处理多余实参:f(x,*args,**kargs)user1@ubuntu:~$ pythonPython 2.7.3 (default, Sep 26 2013, 20:03:06) [GCC 4.6.3] on linux2Type "help", "copyright", "credits" or "license" for原创 2013-12-02 18:24:11 · 1718 阅读 · 0 评论 -
python return语句
函数返回值: 1)函数被调用后会返回一个指定的值 2)函数调用后默认返回None 3)return返回值 4)返回值可以是任意类型 5)return执行后,函数终止 6)区分返回值和打印user1@ubuntu:~$ pythonPython 2.7.3 (default, Sep 26 2013,原创 2013-12-02 18:21:31 · 5388 阅读 · 0 评论 -
python函数全局变量和局部变量
#!/usr/bin/python#coding:utf8x = 'i am global var'#全局变量def fun(): x = 100 #局部变量 global y #强制声明全局变量 y = 200 print xfun() #局部变量 x=100print x #全局变量原创 2013-12-02 18:20:06 · 4437 阅读 · 0 评论 -
python函数形参和实参
#!/usr/bin/python#coding:utf8 #中文输入方式1#coding=utf8 #中文输入方式2#encoding:utf8 #中文输入方式3#encoding=utf8 #中文输入方式4#-*- coding:utf8 -*-#中文输入方式5print '*'*35print "实现输入两个变量的比较功能:"def fun(x,y):#原创 2013-12-02 18:16:43 · 5517 阅读 · 0 评论 -
python--流程控制语句
python流程控制语句python使用缩进作为其语句分组的方法,建议使用4个空格代替缩进。 (1)if语句: if expression: statement(s) expression:逻辑值,主要用于判断语句中,用来判断 --一个字符串是否为空原创 2013-11-27 18:03:16 · 1600 阅读 · 0 评论 -
python--数据类型
python数据类型 Type():查看数据类型数字:整型(int范围-2147483648到2147483647)、长整型(123l或者123L)、浮点型、复数型(3.14j) 字符串、元组和列表都是序列!!!字符串和元组不可变,即不能修改其内部元素的值。 序列两个特点就是索引操作和切片操作。索引操作符:[0]取第一个,[-1]取倒数第一个切片操作原创 2013-11-27 18:02:14 · 1771 阅读 · 0 评论 -
Python--变量/运算符/表达式
1.python变量 python变量名称只是用来引用内存中存储数据的标签;内存中相同的存储数据可以有多个标签,即多个变量名称。变量名有字母、数字、下划线组成,数字不能开头,不可以使用关键字。变量赋值:变量声明和定义的过程。eg:a=1,id(a)获取a的地址。2.python运算符与表达式 —赋值运算符:=、+=、-=、*=、/=、%=原创 2013-11-27 17:58:57 · 3289 阅读 · 0 评论 -
python--脚本语言
1.进入pythonPython,一个解释型、面向对象的、带有动态语义的高级程序设计语言。1989年阿姆斯特丹,圣诞节,Guido van Rossum第一个python版本。Python编程语言中的定位:--脚本语言(scripting language),高阶动态编程语言Python特征:简单易学,解释性&编译性语言,面向对象,高级语言,可扩展性及可嵌入性,免费、开源,丰富原创 2013-11-27 17:54:33 · 3539 阅读 · 0 评论