# 文字列の指定した位置の文字を取り出す(String.charAt) > 指定した位置にある文字を返します。 - カテゴリ:テキスト(text) - ブロック:文字列 "" の ○ 番目の文字 - URL:https://makecode.minecraft-okinawa.com/reference/text/char-at/ - Pythonでの名前:String.char_at - 公式データ取得日:2026-11-13 - 動作確認:確認待ち ## JavaScript ```javascript "".charAt(0) ``` ## Python ```python "".char_at(0) ``` ## 引数 | 名前 | 値 | 意味 | |---|---|---| | index | 数値 | 目的の文字の位置を 0 から始まる値で指定します。 | ## 使用例 ### You can find out which character is at any place in some text. You might have text thats says "Hello there!". The character at position 6 is 't'. The word "Hello" plus the space have positions 0 - 5, so, 't' is at position 6. To get the character at this position, the letter 't', you could use a blocks like this: ```javascript let greeting = "Hello there!"; let tee = greeting.charAt(6); ``` ```python greeting = "Hello there!" tee = greeting.char_at(6) ``` ### Make a funny new sentence from an existing sentence by choosing every other letter. ```javascript let sentence = "Cinnamon vanilla latte"; let funnySentence = ""; for (let i = 0; i < sentence.length; i++) { if (i % 2 > 0) { funnySentence = funnySentence + sentence.charAt(i); } } ``` ```python sentence = "Cinnamon vanilla latte" funnySentence = "" for i in range(len(sentence)): if i % 2 > 0: funnySentence = funnySentence + sentence.char_at(i) ``` ## 出典 - [MakeCode for Minecraft 公式リファレンス(String.charAt)](https://minecraft.makecode.com/reference/text/char-at) 執筆:鈴木孝昌(現役プロジェクトマネージャー/マイクラカップ指導者)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)