字幕表 動画を再生する 字幕スクリプトをプリント 翻訳字幕をプリント 英語字幕をプリント Welcome back for Unit 3. レッスン3にようこそ This unit introduces the next big idea we need for a web crawler, 構造化データであるWebクローラに必要な 次の概念を紹介します which is structured data. このレッスンが終わるまでに あなたはWebクローラの作成を終えますよ And by the end of this unit you will have finished building a working web crawler. 今まで学習した中で構造化データに最も近いものは レッスン1で紹介し The closest thing we've seen so far to structured data レッスン2で実際に使用した文字列データ型です is the string data type introduced in Unit 1 and used 文字列が構造化データの一種なのは in many of the procedures in Unit 2. 文字列を文字に分解できるからです A string is a kind of structured data, and that's because 文字列は文字の連続ですが その文字列の部分列を操作することができます we can break it down into its characters. しかし文字列でできることは少し制限されます The string has a sequence of characters, 文字列に置けるのは文字のみだからです and we can operate on sub sequences of the string. 今回はリストデータ型を紹介します What we could do with strings was somewhat limited, though, リストは文字列よりもはるかに強力です because the only thing we can put in a string is a character. 文字列はすべての要素が文字でなければなりませんが Today, we're going to introduce the list data type, リストは何でも要素にすることが可能です and lists are much more powerful than strings, 文字と文字列のどちらも可能ですし so whereas for a string, all of the elements had to be characters, 数値や別のリストも可能です in a list, the elements can be anything we want. 例を見てみましょう They could be characters. They could be strings. 文字列を作成する時 シングルまたはダブルクォーテーションで They could be numbers. They could also be other lists. 囲まれた一連の文字を置きます Let's look at an example. これが文字列の例です When we created a string, we just put a sequence of characters 代入を使用することで 文字列を変数に保持することができます surrounded by either single or double quotes. リストではリストを特定するために クォーテーションではなく Here's an example of a string, 角括弧を使用します 要素はコンマで区切ります and we could store that string in a variable by using an assignment. 文字列と同じく 変数に作成したリストを代入できます With a list, instead of using quotes to identify the list ですから変数pにこのリストを保持することができます we use square brackets, and the elements are separated by commas. 文字列では要素を選択するために角括弧を使用します And just like with a string, we can assign the list that we created 要素ゼロをインデックス化する際 一連の文字である文字列の1つ目の要素を得ます to a variable, so we'll store that list in the variable "p." ここではyです With a string, we could use the square brackets リストでも角括弧を使用して 要素にアクセスすることができます to select elements, and when we index element 0, 例えばp[0]を行うと we'll get the first element of the string, a sequence of that character, pの1つ目の要素を評価します which is the character "y." これはyを含んだ文字列になります With lists, we can also use square brackets to access elements, 文字列では角括弧内にコロンを使用することで so if we do p[0], 1文字以上の部分列を選ぶことができます that will evaluate to the first element of p, ここでは2の位置から4の位置まで選んでいます which is the string containing the single letter y. これにより文字列の3つ目と 4つ目の文字が得られます With strings, we saw that we could use the colon inside the square brackets これが部分列である文字列bbです to select a sub string of more than 1 character. リストでも同様です Here we're selecting from position 2 through position 4. 2の位置から4の位置までを選択できます That will give us the third and fourth characters of the string, しかし文字列を返す代わりに これらの要素を含んだリストを返します which is the sub sequence, the string "bb." 変数pの3つ目と4つ目の要素のリストが得られます We can do the same thing with lists. リストはご覧のとおりです We can select from position 2 to position 4, リストを作成する一般的な文法は but instead of returning a string, it will return a list 角括弧とそれに続く式の 任意の数のリストになります containing those elements. 数式はコンマで区切られます It will give us a list of the third and fourth element 左右たった2つの角括弧を使うことで リストが作成できます of the variable p, which is the list that we have here. これにより要素ゼロを含むリストを 作成することができます The general grammar for constructing a list これは空のリストとしても知られています is to have a square bracket followed by a list 要素1を含むリストを作成できます of any number of expressions where the expressions これは角括弧の間に要素を1つ置きます are separated by commas. これが作成した要素を1つ含むリストです 数値3です We could create a list using just 2 brackets, 1つ目の例で行ったように たくさんの要素を含むリストも作成できます a left bracket and a right bracket, and this would create a list その場合すべての文字列をコンマで区切ります containing 0 elements, also known as the empty list. We could create a list containing 1 element. That would be the square brackets with 1 element between them. Here we've created a list containing just 1 element, which is the number 3. Or we could create a list with many elements, as we did in the first example, where we have all of the strings separated by commas.
B1 中級 日本語 文字 リスト 変数 レッスン 使用 データ イントロダクション - コンピュータサイエンス入門 (Introduction - Intro to Computer Science) 445 36 羅紹桀 に公開 2021 年 01 月 14 日 シェア シェア 保存 報告 動画の中の単語