Home > Backend Development > Python Tutorial > The path to learning Python for beginners

The path to learning Python for beginners

巴扎黑
Release: 2017-08-02 13:29:40
Original
1499 people have browsed it

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" # 输出连接的字符串
Copy after login

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
}
}
Copy after login

//m.sbmmt.com/python-tutorials-375819.html

3. Function

def square(x):
return x**2
>>> square
<function square at 0x031AA230>
>>> dir(square)
[&#39;__call__&#39;, &#39;__class__&#39;, &#39;__closure__&#39;, &#39;__code__&#39;, &#39;__defaults__&#39;, &#39;__delattr__&#39;, &#39;__dict__&#39;, &#39;__doc__&#39;, &#39;__format__&#39;,&#39;__get__&#39;, &#39;__getattribute__&#39;, &#39;__globals__&#39;, &#39;__hash__&#39;, &#39;__init__&#39;, &#39;__module__&#39;, &#39;__name__&#39;, &#39;__new__&#39;,&#39;__reduce__&#39;, &#39;__reduce_ex__&#39;, &#39;__repr__&#39;, &#39;__setattr__&#39;, &#39;__sizeof__&#39;, &#39;__str__&#39;, &#39;__subclasshook__&#39;,&#39;func_closure&#39;, &#39;func_code&#39;, &#39;func_defaults&#39;, &#39;func_dict&#39;, &#39;func_doc&#39;, &#39;func_globals&#39;, &#39;func_name&#39;]
Copy after login

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, &#39;r&#39;)    for line in fo:        print line
Copy after login

//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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template