After welearn the introduction to Python, we need to start learning the basics of Python, which is the primary stage of learning. Next, let’s take a look at what you need to learn in the early stages of Python.
1. Grammar
#!/usr/bin/python # -*- coding: UTF-8 -*- str = 'Hello World!' print str # 输出完整字符串 print str[0] # 输出字符串中的第一个字符 print str[2:5] # 输出字符串中第三个至第五个之间的字符串 print str[2:] # 输出从第三个字符开始的字符串 print str * 2 # 输出字符串两次 print str + "TEST" # 输出连接的字符串
http://blog.csdn.net/u011955252/article/details/51273863
2.Operation method
for(i=1;i<=n;++i) { for(j=1;j<=n;++j) { c[ i ][ j ]=0; //该步骤属于基本操作 执行次数:n^2 for(k=1;k<=n;++k) c[ i ][ j ]+=a[ i ][ k ]*b[ k ][ j ]; //该步骤属于基本操作 执行次数:n^3 } }
//m.sbmmt.com/python-tutorials-375819.html
3. Function
def square(x): return x**2 >>> square <function square at 0x031AA230> >>> dir(square) ['__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__doc__', '__format__','__get__', '__getattribute__', '__globals__', '__hash__', '__init__', '__module__', '__name__', '__new__','__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__','func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name']
http: //m.sbmmt.com/python-tutorials-375824.html
4. Module
//m.sbmmt.com/python-tutorials- 375825.html
5. Data flow
import osnames = os.listdir(src)for name in names: srcname = os.path.join(src, name) fo = open(srcname, 'r') for line in fo: print line
//m.sbmmt.com/python-tutorials-375827.html
The above is the detailed content of The path to learning Python for beginners. For more information, please follow other related articles on the PHP Chinese website!