<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>itlabo</author_name>
  <author_url>https://blog.hatena.ne.jp/itlabo/</author_url>
  <blog_title>フロントエンドエンジニアのスターティングノート</blog_title>
  <blog_url>https://www.flavor-of-life.com/</blog_url>
  <categories>
    <anon>Python</anon>
  </categories>
  <description>はじめに 文字列の先頭文字の判定によって処理を分けたい時はよくあるパターンです。 Pythonでは非常に簡単に先頭文字を切り出す方法があります。 今回は、Pythonで文字列の先頭3文字を取得する方法について詳しく説明します。 単純に先頭3文字を切り出す方法 Pythonでは、「変数[開始位置:終了位置]」とシンプルに記述することで、文字列の先頭3文字を取得することができます。 具体的にプログラムを見てみましょう。 text = &quot;Python&quot; mozi3 = text[0:3] print(mozi3) # 実行結果: Pyt 先頭文字の場合は、省略して書くこともできます。 text = …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwww.flavor-of-life.com%2Fentry%2Fpython_initial_string_3&quot; title=&quot;【Python】文字列操作を使って先頭3文字を切り出して取得する - フロントエンドエンジニアのスターティングノート&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2025-04-24 04:31:42</published>
  <title>【Python】文字列操作を使って先頭3文字を切り出して取得する</title>
  <type>rich</type>
  <url>https://www.flavor-of-life.com/entry/python_initial_string_3</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
