打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
python核心编程学习笔记
1:
   raw_input()
2: 
 '//' stands for floating divide,and should know the difference between '/' and '//'
3:
'**' means power, for example 2**3 = 8; 2**1 = 2;
4:
enumerate, 
for example
for index, ch in enumerate(str): 
    print index
5:
In the operations of file, '+' = 'rw', and 'a' means that add something to the end of file.
6:
class Test(object):
    class_variable = 'andy'
    pass
The point is to understand how use 'class variable'
7:
sys.platform, sys.version
8:
functional helper method:
range(start, end, step);
type(obj)
dir(obj)
9:
understand how use '\' and ';'
10:
comprehend the follow lines
ls = os.linesep
a = ['and', 'hell']
file.writelines(["%s%s" % (x, ls) for x in a])
11:
understand the means of a[::n]
12:
 try to find the same and difference among the follow lines
(a)
  a = b = 2.0
(b) a = 2.0 ; b = a;
(c) a = 2.0;  b = 2.0;
(d) a = 2.0; b = 1.8 + 0.2
id(a) == id(b) == a is b
notes, int and string have another explains
when I test, python can cache from -5 to 257, and it will change, please don't use this property
13:
repr(s); return string
if inistance (num, (int, long):
    print 'hellp'
14: 
max and reduce
http://blog.xupeng.me/2008/02/19/python-function-max-and-reduce/
sort(reverse=True) stands for descending order
enumerate(a) generate [index, column]
15:
How to use zip
a = [1, 2]; b =['a', 'b']
zip(a,b); return [(1, 'a'), (2, 'b')]
test = zip(a,b)
c, d = zip(*test) 
http://apps.hi.baidu.com/share/detail/35028002
16:
Generally speeking, in consideration of performance, we should not write repeated funtion call in the circle. For example:
while i < len(my_string):
    print i
we shoud do like follow:
length = len(my_string)
while i < lenght:
    pass
In addition 
for substring in my_string[1:]
   if substring not in a + b
       pass
17
from string import Template
s = Template("I'm ${name}")
pritn s.substitute(name="andy")
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
6 个值得玩味的 Python 代码
Python进阶05 循环设计
Python语言编程系列008----enumerate()及zip()函数的使用例子
你想不到的,那些在 Python 中输出列表的技巧
主流编程语言简单代码示例看语言风格
知识记录:python如何通过反射机制处理对象?
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服