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获取Linux下文件版本信息、公司名和产品名的方法
Oct 05 Python
Python中的匿名函数使用简介
Apr 27 Python
Python三级目录展示的实现方法
Sep 28 Python
Python使用requests及BeautifulSoup构建爬虫实例代码
Jan 24 Python
Python 利用内置set函数对字符串和列表进行去重的方法
Jun 29 Python
利用Python进行数据可视化常见的9种方法!超实用!
Jul 11 Python
Django之form组件自动校验数据实现
Jan 14 Python
Python pyautogui模块实现鼠标键盘自动化方法详解
Feb 17 Python
python GUI库图形界面开发之PyQt5窗口控件QWidget详细使用方法
Feb 26 Python
python json 递归打印所有json子节点信息的例子
Feb 27 Python
超级详细实用的pycharm常用快捷键
May 12 Python
Pycharm连接远程服务器并远程调试的全过程
Jun 24 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
一道求$b相对于$a的相对路径的php代码
2010/08/08 PHP
php最简单的删除目录与文件实现方法
2014/11/28 PHP
简单的无缝滚动程序-仅几行代码
2007/05/08 Javascript
DOM下的节点属性和操作小结
2009/05/14 Javascript
判断用户是否在线的代码
2011/03/05 Javascript
妙用Jquery的val()方法
2012/06/27 Javascript
如何用jquery控制表格奇偶行及活动行颜色
2014/04/20 Javascript
JavaScript闭包函数访问外部变量的方法
2014/08/27 Javascript
Jquery ajax基础教程
2015/11/20 Javascript
js验证框架实现代码分享
2016/05/18 Javascript
jQuery制作网页版选项卡
2016/07/28 Javascript
Js操作DOM元素及获取浏览器高宽的简单方法
2016/09/08 Javascript
AngularJS中run方法的巧妙运用
2017/01/04 Javascript
Android中Okhttp3实现上传多张图片同时传递参数
2017/02/18 Javascript
获取本机IP地址的实例(JavaScript / Node.js)
2017/11/24 Javascript
jQuery 实现倒计时天,时,分,秒功能
2018/07/31 jQuery
Spring boot 和Vue开发中CORS跨域问题解决
2018/09/05 Javascript
layui加载表格,绑定新增,编辑删除,查看按钮事件的例子
2019/09/06 Javascript
Jquery Fade用法详解
2020/11/06 jQuery
Python脚本实现DNSPod DNS动态解析域名
2015/02/14 Python
Python多继承以及MRO顺序的使用
2019/11/11 Python
Django修改app名称和数据表迁移方案实现
2020/09/17 Python
Python抖音快手代码舞(字符舞)的实现方法
2021/02/07 Python
python元组拆包实现方法
2021/02/28 Python
IE支持HTML5的解决方法
2009/10/20 HTML / CSS
实用求职信范文分享
2013/12/25 职场文书
小学教师培训方案
2014/06/09 职场文书
2014教师教育实践活动对照检查材料思想汇报
2014/09/21 职场文书
求职自荐信怎么写
2015/03/04 职场文书
小学生五一劳动节演讲稿
2015/03/18 职场文书
资料员岗位职责范本
2015/04/13 职场文书
承诺书的签字人,需不需要承担相应的责任?
2019/07/09 职场文书
如何用JavaScript学习算法复杂度
2021/04/30 Javascript
Python中的min及返回最小值索引的操作
2021/05/10 Python
Java各种比较对象的方式的对比总结
2021/06/20 Java/Android
德生BCL3000抢先使用感受和评价
2022/04/07 无线电