This article describes the summary of the python attention points
1, arithmetic operations in the python2.7/operation is not accurate enough to reference the _future_ class library
#!/usr/bin/env python#-*-coding:utf-8-*-from _future_ Import Division val = 9/2 print (val)
2. Range and Xrange
"python2.7" xrange the performance of the loop is better than range, especially when the return is very large. Try to use xrange, unless you are going to return a list.
Only range in python3.5 is the same as xrange function!
#!/usr/bin/env python#-*-conding:utf-8-*-s1 = range (1,10) s2 = xrange (1,5) print (S1) print (S2) for s in S2: print S
3. Judging the use of in or not
#!/usr/bin/env python#-*-conding:utf-8-*-li = "Alex SB" ret = "Al" in Liprint (ret) # = + Trueli = ["Alex", "Eric", "Rain "] ret =" Al "In Liprint (ret) # = False
4. Classes and objects
Description of the "Python" Str class method