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使用mysqldb连接数据库操作方法示例详解
Dec 03 Python
python数据结构之二叉树的建立实例
Apr 29 Python
Python json模块使用实例
Apr 11 Python
Python实现统计单词出现的个数
May 28 Python
python 实现批量xls文件转csv文件的方法
Oct 23 Python
Python docx库用法示例分析
Feb 16 Python
python 字符串常用方法汇总详解
Sep 16 Python
pytorch 修改预训练model实例
Jan 18 Python
Python3.8.2安装包及安装教程图文详解(附安装包)
Nov 28 Python
Python实现中英文全文搜索的示例
Dec 04 Python
PyTorch梯度裁剪避免训练loss nan的操作
May 24 Python
python脚本框架webpy模板赋值实现
Nov 20 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系统流量分析的程序
2006/10/09 PHP
新安装的MySQL数据库需要注意的安全知识
2008/07/30 PHP
php警告Creating default object from empty value 问题的解决方法
2014/04/02 PHP
ThinkPHP实现动态包含文件的方法
2014/11/29 PHP
Zend Framework框架Smarty扩展实现方法
2016/03/22 PHP
jquery ajax jsonp跨域调用实例代码
2013/12/11 Javascript
Javascript表单验证要注意的事项
2014/09/29 Javascript
常用的Javascript设计模式小结
2015/12/09 Javascript
JavaScript几种数组去掉重复值的方法推荐
2016/04/12 Javascript
jQuery简易时光轴实现方法示例
2017/03/13 Javascript
vue 组件使用中的一些细节点
2018/04/25 Javascript
详解vue 自定义marquee无缝滚动组件
2019/04/09 Javascript
express + jwt + postMan验证实现持久化登录
2019/06/05 Javascript
JavaScript 预解析的4种实现方法解析
2019/09/03 Javascript
uni-app 组件里面获取元素宽高的实现
2019/12/27 Javascript
[01:16:50]DOTA2-DPC中国联赛 正赛 Phoenix vs CDEC BO3 第一场 3月7日
2021/03/11 DOTA
Python中实现对Timestamp和Datetime及UTC时间之间的转换
2015/04/08 Python
Python读写Json涉及到中文的处理方法
2016/09/12 Python
名片管理系统python版
2018/01/11 Python
python读取文本中数据并转化为DataFrame的实例
2018/04/10 Python
python实现连连看游戏
2020/02/14 Python
Matplotlib使用字符串代替变量绘制散点图的方法
2020/02/17 Python
opencv python在视屏上截图功能的实现
2020/03/05 Python
pandas.DataFrame.drop_duplicates 用法介绍
2020/07/06 Python
python 6行代码制作月历生成器
2020/09/18 Python
CSS3让登陆面板3D旋转起来
2016/05/03 HTML / CSS
德国箱包网上商店:koffer24.de
2016/07/27 全球购物
英国著名国际平价时尚男装品牌:Topman
2016/08/27 全球购物
意大利香水和彩妆护肤品购物网站:Ditano
2017/08/13 全球购物
阿波罗盒子:Apollo Box
2017/08/14 全球购物
综合实践活动方案
2014/02/14 职场文书
房产转让协议书
2014/04/11 职场文书
个人合伙协议书范本
2014/10/14 职场文书
一个都不能少观后感
2015/06/04 职场文书
改造DE1103三步曲
2022/04/07 无线电
错误码NET::ERR_CERT_DATE_INVALID证书已过期解决方法?
2022/07/07 数码科技