ホームページ  >  記事  >  バックエンド開発  >  初心者のための Python 学習への道

初心者のための Python 学習への道

巴扎黑
巴扎黑オリジナル
2017-08-02 13:29:401419ブラウズ

Python の入門を学習したら、、学習の第一段階である 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 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。