摘要: If we execute these assignment statements: We know that a and b both refer to a string, but we don’t know whether they refer to the same str... 阅读全文
posted @ 2014-07-13 18:41 平静缓和用胸音说爱 阅读(254) 评论(0) 推荐(0) 编辑
摘要: There are several ways to delete elements from a list. If you know the index of the element you want, you can use pop: pop modifies the list... 阅读全文
posted @ 2014-07-13 17:21 平静缓和用胸音说爱 阅读(173) 评论(0) 推荐(0) 编辑
摘要: To add up all the numbers in a list, you can use a loop like this: Total is initialized to 0. Each time through the loop, x gets one element... 阅读全文
posted @ 2014-07-13 16:59 平静缓和用胸音说爱 阅读(302) 评论(0) 推荐(0) 编辑
摘要: Python provides methods that operate on lists. For example, append adds a new element to the end of a list, extend takes a list as an argument and app... 阅读全文
posted @ 2014-07-13 15:06 平静缓和用胸音说爱 阅读(209) 评论(0) 推荐(0) 编辑
摘要: The + operator concatenates lists: Similarly, the * operator repeats a list a given number of items:List slicesThe slice operator also works... 阅读全文
posted @ 2014-07-13 14:51 平静缓和用胸音说爱 阅读(281) 评论(0) 推荐(0) 编辑
摘要: The most common way to traverse the elements of a list is with a for loop. The syntax is the same as for strings: This works well if you onl... 阅读全文
posted @ 2014-07-13 14:38 平静缓和用胸音说爱 阅读(221) 评论(0) 推荐(0) 编辑
摘要: The syntax for accessing the elements of a list is the same as for accessing the characters of a string – the bracket operator ([ ]). The expression i... 阅读全文
posted @ 2014-07-09 22:03 平静缓和用胸音说爱 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Like a string, a list is a sequence of values. In a string, the values are characters; in a list, they can be any type. The values in list are called ... 阅读全文
posted @ 2014-07-09 21:30 平静缓和用胸音说爱 阅读(265) 评论(0) 推荐(0) 编辑
摘要: #! /usr/bin/python# -*- coding: utf-8 -*-### “Recently I had a visit with my mom and we realized that the two digits that# make up my age when reverse... 阅读全文
posted @ 2014-07-06 17:54 平静缓和用胸音说爱 阅读(289) 评论(0) 推荐(0) 编辑
摘要: This question is based on a Puzzler that was broadcast on the radioprogram Car Talk1:“I was driving on the highway the other day and I happened to not... 阅读全文
posted @ 2014-07-05 19:56 平静缓和用胸音说爱 阅读(268) 评论(0) 推荐(0) 编辑