{"id":162,"date":"2025-02-26T21:16:07","date_gmt":"2025-02-26T12:16:07","guid":{"rendered":"https:\/\/itexplore.org\/jp\/?p=162"},"modified":"2025-02-26T21:16:09","modified_gmt":"2025-02-26T12:16:09","slug":"substring-from-end-python","status":"publish","type":"post","link":"https:\/\/itexplore.org\/jp\/tips\/substring-from-end-python\/","title":{"rendered":"Python\u3067\u5f8c\u308d\u304b\u3089\u90e8\u5206\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b"},"content":{"rendered":"<p>Python\u3067\u90e8\u5206\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b\u306b\u306f\u30b9\u30e9\u30a4\u30b9\u3092\u4f7f\u3044\u307e\u3059\u3002<code>string[start:stop]<\/code> \u306e\u3088\u3046\u306b\u958b\u59cb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u7d42\u4e86\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u6307\u5b9a\u3057\u3066\u90e8\u5206\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3057\u307e\u3059\u304c\u3001\u30b9\u30e9\u30a4\u30b9\u306e<strong><span data-color=\"#fffd6b\" style=\"background: linear-gradient(transparent 60%,rgba(255, 253, 107, 0.7) 0);\" class=\"vk_highlighter\">\u958b\u59cb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u8ca0\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4e0e\u3048\u308b<\/span><\/strong>\u3053\u3068\u3067\u3001\u672b\u5c3e\u304b\u3089\u90e8\u5206\u6587\u5b57\u5217\u3092\u62bd\u51fa\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p><h2 class=\"wp-block-heading\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2><div class=\"input-field-container source-code-container\"><pre class=\"wp-block-code\"><code>\ndef substring_from_end(string, length):\n    \"\"\"\n    \u6587\u5b57\u5217\u306e\u672b\u5c3e\u304b\u3089\u6307\u5b9a\u3055\u308c\u305f\u9577\u3055\u306e\u90e8\u5206\u6587\u5b57\u5217\u3092\u8fd4\u3057\u307e\u3059\u3002\n\n    \u30d1\u30e9\u30e1\u30fc\u30bf:\n    string (str): \u90e8\u5206\u6587\u5b57\u5217\u3092\u62bd\u51fa\u3059\u308b\u5143\u306e\u6587\u5b57\u5217\u3002None \u306e\u5834\u5408\u306f\u7a7a\u306e\u6587\u5b57\u5217\u3092\u8fd4\u3057\u307e\u3059\u3002\n    length (int): \u62bd\u51fa\u3059\u308b\u90e8\u5206\u6587\u5b57\u5217\u306e\u9577\u3055\u3002\n\n    \u623b\u308a\u5024:\n    str: \u6587\u5b57\u5217\u306e\u672b\u5c3e\u304b\u3089\u62bd\u51fa\u3057\u305f\u90e8\u5206\u6587\u5b57\u5217\u3002\n    \"\"\"\n    if string is None:\n        return \"\"\n\n    return string[-length:]\n<\/code><\/pre><a id=\"copy-source-code-Python-substring_from_end\" class=\"action-button enable copy-source-code\" title=\"\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002\"><i class=\"fa-regular fa-copy\"><\/i><\/a><\/div><p class=\"border-spacer\"><\/p><h3 class=\"wp-block-heading\">\u5b9f\u884c\u7d50\u679c<\/h3><div class=\"input-field-container source-code-container\"><pre class=\"wp-block-code\"><code># \u4f8b1: None \u306e\u5834\u5408\nstring = None\nlength = 3\nsubstring = substring_from_end(string, length)\nprint(substring)  # \u51fa\u529b: \"\"\n\n# \u4f8b2: \u6587\u5b57\u5217 \"abcdef\" \u306e\u672b\u5c3e\u304b\u30893\u6587\u5b57\u3092\u53d6\u308a\u51fa\u3059\u5834\u5408\nstring = \"abcdef\"\nlength = 3\nsubstring = substring_from_end(string, length)\nprint(substring)  # \u51fa\u529b: \"def\"\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Python\u3067\u90e8\u5206\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b\u306b\u306f\u30b9\u30e9\u30a4\u30b9\u3092\u4f7f\u3044\u307e\u3059\u3002\u958b\u59cb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u8ca0\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u672b\u5c3e\u304b\u3089\u90e8\u5206\u6587\u5b57\u5217\u3092\u62bd\u51fa\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":163,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"vkexunit_cta_each_option":"","footnotes":""},"categories":[4],"tags":[13],"class_list":["post-162","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","tag-python"],"_links":{"self":[{"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/posts\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":2,"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/posts\/162\/revisions\/165"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/media\/163"}],"wp:attachment":[{"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itexplore.org\/jp\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}