初级Python的学习之路

巴扎黑
发布: 2017-08-02 13:29:40
原创
1599人浏览过

在我们学习python入门之后,我们就需要开始对python的基础进行学习,也就是初级阶段的学习。接下来我们来看看python的初级阶段需要学习哪些东西。

1.语法

1

2

3

4

5

6

7

8

9

10

11

#!/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.运算方法

1

2

3

4

5

6

7

8

9

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

立即学习Python免费学习笔记(深入)”;

3.函数

1

2

3

4

5

6

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://www.php.cn/python-tutorials-375824.html

4.模块

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

5.数据流

1

2

3

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

以上就是初级Python的学习之路的详细内容,更多请关注php中文网其它相关文章!

python速学教程(入门到精通)
python速学教程(入门到精通)

python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号