python笔记(1) 关于我们应不应该继续学习python


Posted in Python onOctober 24, 2012

以前面试的时候会被问到,linux熟不熟呀?对于这种问题:我总会尴尬地回答,“额..了解一点”。

然而,我大学毕业的时候,连linux的虚拟机都没装过,更别提系统熟不熟悉了。虽然我了解一点这个系统可以完全通过命令来操作。后来工作了,有时候写点代码,svn提交上去,服务器是Linux的,自己也是在windows上跑跑客户端。记得有个项目,要求用shell来启动java程序,你知道那时候我是怎么做的吗?把他们的shell拿来,问哪几个地方要改的,然后改下要启动java类的路径。ok了,完全不去理解里面的意思。到最后又一次面试的时候,不得不坦白:不是太了解Linux命令。

有人可能会说:Linux命令没什么难啊。花几天时间就好了。现在的我也会这么和完全不懂Linux的朋友这么说。可是如果我不跨出学习命令的第一步。我未来的很长一段时间都不得不在面试的时候再一次尴尬。

回到正题,我们到底该不该去学习现在看来没什么用而确实是不错的东西呢?

我的回答是:如果你的确是有余力,并愿意向自己投资的话,我觉得是有必要的。

1,这种额外的学习会让你的周末变得充实。

2,当学习到一定程度的时候,会对事物有新的看法。

3,面试的时候,你多了一块筹码。

4,有一个理论:学习的越多,知道自己不知道的越多。(知识面越广,你所看到的世界就越大!)

就像情歌里唱的那样:”我们一直都忘了要到一座桥,到对方心里瞧一瞧“,我想我们是不是也忘了去到一座桥,去别的地方瞧一瞧呢!呵呵

所以让我们一起进入PYTHON世界吧!

python笔记(1)

关于Python,如果你要学习,建议大家查看一下网站:(因为本人也是刚刚决定收集点零碎时间来学习下它,推荐可能并不是最好的)

http://book.huihoo.com/dive-into-python/5.4_zh-cn/html/toc/index.html

《Dive to python》
http://docs.python.org/
http://woodpecker.org.cn/
http://code.google.com/intl/zh-CN/edu/languages/google-python-class/introduction.html

刚接触python我觉得很棒,因为安装个软件,马上就能来个HelloWorld!
也许我们早就过了兴奋的年纪,事实上,我是想说python绝对是让你放轻松学习的语言。

1,函数声明用 def

def buildConnectionString(params):

2,导入模块:import

import odbchelper

在导入模块时是python编译器去自己的环境变量制定的路径路去找这个模块,如果要导入的模块是自定义的路径下,就必须把这个路径先放进环境变量中去。

import sys 
sys.path.append('/my/new/path')

3,if_else语句:(python通过缩进来控制代码块,代替了java中的“{}”)
if n > 1: 
return n * fib(n - 1) 
else: 
print 'end of the line' 
return 1

4,内置数据类型List:
List li = ["a", "b", "mpilgrim", "z", "example"]

用“[]”包起来。

A.用for var in list,可以遍历一个list。在遍历的时候不要试着增加和删除元素哦!

squares = [1, 4, 9, 16] 
sum = 0 
for num in squares: 
sum += num 
print sum ## 30

B.用in来判断一个元素是否在list中:
list = ['larry', 'curly', 'moe'] 
if 'curly' in list: 
print 'yay

C.list其他的方法:
list.append(elem) -- adds a single element to the end of the list. Common error: does not return the new list, just modifies the original. 
list.insert(index, elem) -- inserts the element at the given index, shifting elements to the right. 
list.extend(list2) adds the elements in list2 to the end of the list. Using + or += on a list is similar to using extend(). 
list.index(elem) -- searches for the given element from the start of the list and returns its index. Throws a ValueError if the element does not appear (use "in" to check without a ValueError). 
list.remove(elem) -- searches for the first instance of the given element and removes it (throws ValueError if not present) 
list.sort() -- sorts the list in place (does not return it). (The sorted() function shown below is preferred.) 
list.reverse() -- reverses the list in place (does not return it) 
list.pop(index) -- removes and returns the element at the given index. Returns the rightmost element if index is omitted (roughly the opposite of append()).

D.其他关于list的例子:
 list = ['larry', 'curly', 'moe'] 
list.append('shemp') ## append elem at end 
list.insert(0, 'xxx') ## insert elem at index 0 
list.extend(['yyy', 'zzz']) ## add list of elems at end 
print list ## ['xxx', 'larry', 'curly', 'moe', 'shemp', 'yyy', 'zzz'] 
print list.index('curly') ## 2 list.remove('curly') ## search and remove that element 
list.pop(1) ## removes and returns 'larry' 
print list ## ['xxx', 'moe', 'shemp', 'yyy', 'zzz']

本文纯粹的目的是想让更多的人去学习他们可能因各种借口拒绝学习的东西。
希望你能被我我的鼓动,而有所行动哦!
Python 相关文章推荐
Python使用lxml模块和Requests模块抓取HTML页面的教程
May 16 Python
Python2.7基于笛卡尔积算法实现N个数组的排列组合运算示例
Nov 23 Python
Django 登陆验证码和中间件的实现
Aug 17 Python
pytorch permute维度转换方法
Dec 14 Python
python消费kafka数据批量插入到es的方法
Dec 27 Python
详解python中TCP协议中的粘包问题
Mar 22 Python
python字符串和常用数据结构知识总结
May 21 Python
Laravel框架表单验证格式化输出的方法
Sep 25 Python
python psutil监控进程实例
Dec 17 Python
基于numpy中的expand_dims函数用法
Dec 18 Python
Pandas数据分析的一些常用小技巧
Feb 07 Python
基于Python实现对比Exce的工具
Apr 07 Python
Python的一些用法分享
Oct 07 #Python
Python天气预报采集器实现代码(网页爬虫)
Oct 07 #Python
python代码检查工具pylint 让你的python更规范
Sep 05 #Python
python 基础学习第二弹 类属性和实例属性
Aug 27 #Python
用Python写的图片蜘蛛人代码
Aug 27 #Python
Python模块学习 filecmp 文件比较
Aug 27 #Python
Python模块学习 datetime介绍
Aug 27 #Python
You might like
解析php中session的实现原理以及大网站应用应注意的问题
2013/06/17 PHP
JavaScript iframe的相互操作浅析
2009/10/14 Javascript
利用onresize使得div可以随着屏幕大小而自适应的代码
2010/01/15 Javascript
Extjs4中tree的拖拽功能(可以两棵树之间拖拽) 简单实例
2013/12/08 Javascript
JavaScript禁止页面操作的示例代码
2013/12/17 Javascript
jQuery事件绑定on()、bind()与delegate() 方法详解
2015/06/03 Javascript
js时间戳和c#时间戳互转方法(推荐)
2017/02/15 Javascript
解决bootstrap下拉菜单点击立即隐藏bug的方法
2017/06/13 Javascript
jquery.validate表单验证插件使用详解
2017/06/21 jQuery
webpack 1.x升级过程中的踩坑总结大全
2017/08/09 Javascript
Vue2.0设置全局样式(less/sass和css)
2017/11/18 Javascript
浅谈vue的几种绑定变量的值 防止其改变的方法
2018/03/01 Javascript
JavaScript对象的浅拷贝与深拷贝实例分析
2018/07/25 Javascript
使用Jenkins部署React项目的方法步骤
2019/03/11 Javascript
基于mpvue搭建微信小程序项目框架的教程详解
2019/04/10 Javascript
利用layer实现表单完美验证的方法
2019/09/26 Javascript
vue-router之解决addRoutes使用遇到的坑
2020/07/19 Javascript
[01:32]2016国际邀请赛中国区预选赛CDEC战队教练采访
2016/06/26 DOTA
使用Python的Tornado框架实现一个一对一聊天的程序
2015/04/25 Python
TF-IDF与余弦相似性的应用(一) 自动提取关键词
2017/12/21 Python
对python append 与浅拷贝的实例讲解
2018/05/04 Python
Python图像处理实现两幅图像合成一幅图像的方法【测试可用】
2019/01/04 Python
python+selenium 定位到元素,无法点击的解决方法
2019/01/30 Python
CSS3 中的@keyframes介绍
2014/09/02 HTML / CSS
HTML5实现预览本地图片
2016/02/17 HTML / CSS
HTML5实现直播间评论滚动效果的代码
2020/05/27 HTML / CSS
Funko官方商店:源自美国,畅销全球搪胶收藏玩偶
2018/09/15 全球购物
前台文员岗位职责及工作流程
2013/11/19 职场文书
致1500米运动员广播稿
2014/02/07 职场文书
大学迎新晚会主持词
2014/03/24 职场文书
银行贷款承诺书
2014/03/29 职场文书
团党委领导干部党的群众路线教育实践活动个人对照检查材料思想汇
2014/10/05 职场文书
实习单位鉴定意见
2015/06/04 职场文书
2015年暑假生活总结
2015/07/13 职场文书
Go语言中break label与goto label的区别
2021/04/28 Golang
【海涛解说】史上最给力比赛,挑战DOTA极限
2022/04/01 DOTA