Python的学习
来源:互联网 发布:李昌钰 辛普森 知乎 编辑:程序博客网 时间:2024/06/08 04:44
关于内置函数reverse()及reversed()
reverse():所有元素原地逆序
reversed():不对原表做任何修改,只是返回一个逆序排列后的迭代对象
list('abcdef'):['a', 'b', 'c', 'd', 'e', 'f'] 将序列转换成列表
print (tuple('abcdefg'))('a', 'b', 'c', 'd', 'e', 'f', 'g') 将序列转换成元组
元组:不可变序列
列表:可变序列
zip(列表1,列表2,...):将多个元组或列表对应位置的元素泽河为元组,并返回包含这些元组的列表(Python 2.x)或zip对象(Python 3.x)
aList = [1,2,3]bList = [4,5,6]cList = [7,8,9]dList = zip(aList,bList,cList)print dList[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
locals()
globals()
a = (1,2,3,4,5)b = 'Hello world'def demo(): a = 3 b = [1,2,3] #locals()返回当前作用域所有局部变量和值的字典 print('locals:',locals()) #globals()返回当前作用域内所有全局变量和值的字典 print('globals:',globals())demo()('locals:', {'a': 3, 'b': [1, 2, 3]})
('globals:', {'a': (1, 2, 3, 4, 5), 'b': 'Hello world', '__builtins__': <module '__builtin__' (built-in)>, 'dList': [(1, 4, 7), (2, 5, 8), (3, 6, 9)], '__file__': 'E:/PycharmProjects/Project2/listFile.py', 'aList': [1, 2, 3], '__package__': None, 'cList': [7, 8, 9], 'bList': [4, 5, 6], 'demo': <function demo at 0x016ED830>, '__name__': '__main__', 'filename': 'timeCom.py', 'os': <module 'os' from 'E:\Python\lib\os.pyc'>, '__doc__': None})
0 0
- Python学习-Python的基础知识
- python的学习
- python的twisted 学习
- Python的学习纲要
- python的学习
- python 3.2的学习
- 学习python的网站
- python学习的看法
- python序列的学习
- python datetime的学习
- 学习Python的总结
- python类的学习
- python的字典学习
- 关于Python的学习
- python的学习一
- 学习python的目的
- 学习python的初衷
- 学习python的地方
- python 七种邮件内容发送方法实例
- Volley 传递头部Heards需要注意问题
- Oracle如何创建表空间和用户
- hdu--2042 不容易系列
- 空间数据如此重要,我们怎能错过?
- Python的学习
- Android逆向之旅---Android中如何在非Root设备中获取应用隐私数据
- ibox4412 编译QT5.6 问题
- 静态变量的问题
- 在一个字符串中找到第一个只出现一次的字符
- HDU 1005 Number Sequence
- 转载自豆瓣,前端工程师成长路线
- traceroute程序剖析
- 有了malloc/free为什么还要new/delete?