当前位置: 首页 > news >正文

门户网站区别网站建设 版权归属

门户网站区别,网站建设 版权归属,wordpress禁止加载头部,广告平面设计教程本系列为加州伯克利大学著名 Python 基础课程 CS61A 的课堂笔记整理,全英文内容,文末附词汇解释。 目录 01 Strings 字符串 Ⅰ Strings are An Abstraction. Ⅱ Strings Literals have Three Forms Ⅲ String are Sequences 02 Dictionaries 字典 …

本系列为加州伯克利大学著名 Python 基础课程 CS61A 的课堂笔记整理,全英文内容,文末附词汇解释。

目录

01 Strings 字符串

Ⅰ Strings are An Abstraction.

Ⅱ Strings Literals have Three Forms

Ⅲ String are Sequences

02 Dictionaries 字典

03 Dictionary Comprehensions 字典理解

附:词汇解释


01 Strings 字符串

Ⅰ Strings are An Abstraction.

>>> 'curry = lambda f: lambda x: lambda y: f(x, y)'
'curry = lambda f: lambda x: lambda y: f(x, y)'
>>> exec('curry = lambda f: lambda x: lambda y: f(x, y)')
>>> curry
<function <lambda> at 0x1003c1bf8>
>>> from operator import add
>>> curry(add)(3)(4)
7
Ⅱ Strings Literals have Three Forms
>>> 'I am string'
'I am string'
>>> '您好'
'您好'>>> "I've learned a lot from CS61A"
"I've learned a lot from CS61A">>> """The Zen of Python 
claims, Readability counts. 
Read more: import this."""
'The Zen of Python\nclaims, Readability counts.\nRead more: import this.'

① Single-quoted and double-quoted strings are equivalent.

② A backslash "escapes" the following character.

③ "Line feed" character represents a new line.

Ⅲ String are Sequences

Length and element selection are similar to all sequences.

However, the "in" and "not in" operators match substrings.

When working with strings, we usually care about whole words more than letters.

02 Dictionaries 字典

Dictionaries are collections of key-value pairs.

>>> numerals = {'I': 1, 'V': 5, 'X': 10}
>>> numerals
{'I': 1, 'V': 5, 'X': 10}>>> numerals['I']
1
>>> numerals[0]
Traceback (most recent call last):File "<stdin>", line 1, in <module>
KeyError: 0
>>> numerals['V']
5
>>> numerals['X']
10>>> list(numerals)
['I', 'V', 'X']
>>> numerals.values()
dict_values([1, 5, 10])
>>> list(numerals.values())
[1, 5, 10]
>>> sum(numerals.values())
16>>> {}
{}
>>> {1: {}}
{1: {}}
>>> {1: 'item'}
{1: 'item'}
>>> {1: ['first', 'second'], 3: 'third'}
{1: ['first', 'second'], 3: 'third'}
>>> d = {1: ['first', 'second'], 3: 'third'}
>>> d[1]
['first', 'second']
>>> d[3]
'third'>>> len(d)
2
>>> len(d[1])
2
>>> len(d[3])
5

Dictionary key do have two restrictions.

#Two keys cannot be equal
#There can be at most one value for a given key
>>> {1: 'first', 1: 'second'}
{1: 'second'}#A key of a dictionary cannot be a list or a dictionary(or any mutable type)
#[] or {}
>>> {[1]: 'first'}
Traceback (most recent call last):File "<stdin>", line 1, in <module>
KeyError: unhashable type: 'list'>>> {{}: 'first'}
Traceback (most recent call last):File "<stdin>", line 1, in <module>
KeyError: unhashable type: 'dict'

The first restriction is part of the dictionary abstraction.

The second restriction is tied to Python's underlying implementation of dictionaries.

If you want to associate multiple values with a key, store them all in a sequence value.

03 Dictionary Comprehensions 字典理解

An expression that evaluates to a dictionary using this evaluation procedure:

① Add a new frame with the current frame as its parent.

② Create an empty result dictionary that is the value of the expression.

③ For each element in the iterable value of <iter exp>:

A. Bind <name> to that element in the new frame from step 1.

B. If <filter exp> evaluates to a true value, then add to the result dictionary an entry that

pairs the value of <key exp> to the value of <value exp>.

Example 1: Indexing

def index(keys, values, match):"""Return a dictionary from keys to a list of values for which match(k, v) is a true value.>>> index([7, 9, 11], range(30, 50), lambda k, v: v % k == 0){7: [35, 42, 49], 9: [36, 45], 11: [33, 44]}"""return {k: [v for v in values if match(k, v) for k in keys]}

附:词汇解释

quote / kwoʊt / 引号

single-quote 单引号

double-quote 双引号

equivalent / ɪˈkwɪvələnt / 等同的

habitation 住所

backslash / ˈbækslæʃ / 反斜杠符号

escape / ɪˈskeɪp / 逃跑

mutable / ˈmjuːtəb(ə)l / 可变的

unhashable 不可哈希的

traceback 回溯

underlying 下层的,底层的

pair 配对

http://www.yayakq.cn/news/580515/

相关文章:

  • 亚马逊站外推广网站重庆本土网站
  • 360做网站和推广怎么样住建部定调房地产市场
  • 大庆 网站建设网站建设的单可以刷吗
  • 做物理的网站200网址大全
  • 网站支付的功能如何做wordpress+头像加速
  • 台州做鞋子网站网站建设名牌
  • 山西省城乡住房和建设厅网站pageadmin自助建站系统
  • 做那个类型的网站赚钱wordpress卖
  • 淘宝直播要先建设个网站吗网站语言切换前端可以做么
  • 济南本地网站深圳网站建设收费标准
  • 黄页网站推广app公司做网站怎么做账
  • 大连网站开发价格国家工商企业查询系统
  • 计算机学院网站建设wordpress 用户充值
  • 网站采集功能佛山从事网站建设
  • 简约网站怎么优化wordpress数据库表
  • 开店做网站有域名如何搭建网站
  • 电子商务网站建设的语言及特点乐之网站制作
  • 域名反查网站seo群发软件
  • 常州网站外包德勤管理咨询
  • 课程网站建设的基本原理兰州网站推广建设
  • 宁波网站推广服务wordpress安装无法登录
  • 我帮你建站引导企业做网站
  • 合肥做网站行吗小程序数据库怎么建立
  • 网站建设中最重要的环节换空间网站备案吗
  • 南京明辉建设有限公司网站如何在网站做文档资料
  • 邯郸网站建设渠道怎么建卡盟网站
  • WordPress网站接入公众号重庆未来科技网站建设
  • wordpress网站手机端菜单栏网站使用的主色调
  • 网站建设与运营 就业个人申请开网店怎么注册
  • 俄文视频网站开发企业网查询官网入口