>  기사  >  백엔드 개발  >  초보자를 위한 Python 학습의 길

초보자를 위한 Python 학습의 길

巴扎黑
巴扎黑원래의
2017-08-02 13:29:401420검색

Python 입문을 배운 후에는 학습의 기본 단계인 Python의 기본을 배우기 시작해야 합니다. 다음으로 파이썬 초기 단계에서 배워야 할 내용을 살펴보겠습니다.

1. 구문

#!/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.작동 방법

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
}
}

http://www.php.cn/python-tutorials -375819.html

3. 기능

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;]

http://www.php.cn/python-tutorials-375824.html

http://www.php.cn/ python-tutorials-375825.html

5. 데이터 흐름

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

http://www.php.cn/python-tutorials-375827.html

위 내용은 초보자를 위한 Python 학습의 길의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.