PHP前端开发

初级Python的学习之路

百变鹏仔 3小时前 #Python
文章标签 之路

在我们python-tutorials-375815.html" target="_blank">学习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<p><a href="http://www.php.cn/python-tutorials-375819.html" target="_blank">http://www.php.cn/python-tutorials-375819.html</a></p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/00968c3c2c15" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">Python免费学习笔记(深入)</a>”;</p><p>3.函数</p><pre class="brush:python;toolbar:false">def square(x):return x**2&gt;&gt;&gt; square<function>&gt;&gt;&gt; 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']</function>

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

4.模块

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, 'r')    for line in fo:        print line

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