小结

append() 方法用于在列表末尾添加新的对象。

 

aList = [123, 'xyz', 'zara', 'abc'];
aList.append( 2009 );
print "Updated List : ", aList;
输出:

 

Updated List :  [123, 'xyz', 'zara', 'abc', 2009]


pass:
在编写代码时只写框架思路,具体实现还未编写就可以用 pass 进行占位,使程序不报错,不会进行任何操作。

 

Python enumerate() 函数:

enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中。

Python 2.3. 以上版本可用,2.6 添加 start 参数。

语法:

enumerate(sequence, [start=0])

参数


  • sequence -- 一个序列、迭代器或其他支持迭代对象。
  • start -- 下标起始位置。
  • 返回值

    返回 enumerate(枚举) 对象。

  • >>>seasons = ['Spring', 'Summer', 'Fall', 'Winter']
  • >>> list(enumerate(seasons))
  • [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]
  • >>> list(enumerate(seasons, start=1)) # 下标从 1 开始 [(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]

 

解决Spellchecker inspection helps locate typos and misspelling in your code

idea出现这个是因为词库中没有这个单词,所以提示拼写错误 解决办法:双击下面有虚线的单词——>鼠标右键——>spelling——>save 'xxx' to distionary
 

解决PEP 8: expected 2 blank lines, found 0

https://jingyan.baidu.com/article/9080802237a606fd91c80f29.html

 
 
posted @ 2019-04-03 11:04  aggressive2019  阅读(154)  评论(0编辑  收藏  举报