python 之 函数

pop()函数 :用于移除列表中一个元素(默认最后一个元素),并且返回该元素的值。

语法:list.pop(obj=list[-1]);

aList = [123, 'xyz', 'zara', 'abc'];
print "A List : ", aList.pop();
print "B List : ", aList.pop(2);
结果:
A List :abc
B List :zara

 sys.stdout.write ()  可以进行换行显示

sys.stdout.write sys.stdout.write
time.sleep() 可以进行时间延迟
time.sleep( 1 )  //延迟一秒

enumerate()内置函数 对可迭代/可遍历的对象,将其组成一个索引序列,利用它获得索引和值
sequence=[12,34,34,23,45,76,89]
for i ,j in enumerate(sequence):
    print(i,j)


list1 = ["这", "是", "一个", "测试"]
for index, item in enumerate(list1, 1):
print index, item
输出 1 这 2 是 3 一个 4 测试



 
原文地址:https://www.cnblogs.com/zmztya/p/7242411.html