Ruby → Python チートシート（文字列Stringクラス編）

####凡例
>メソッド名（兼ドキュメントへのリンク）
>【Ruby】例
>【Python】対応する例（シンタックスや結果の違いがわかるようなもの）
> 対応ドキュメントのURL

* ここでは変数 `r = "ルビー"` `p = "パイソン"` としています。
* -&lowast;- encoding: UTF-8 -&lowast;- です。

#INDEX

####[%](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--25)
【Ruby】`"%s vs %s"%[r, p] # => "ルビー vs パイソン"`（※ 引数は配列）
【Python】`"%s vs %s"%(r, p) # => "ルビー vs パイソン"`（※ 引数はタプル）
https://docs.python.org/ja/3/library/stdtypes.html#printf-style-string-formatting

####[&lt;&lt;](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--3C--3C)
【Ruby】`r << p # r => "ルビーパイソン"`
【Python】`p += r # p => "パイソンルビー"`

####[&lt;=&gt;](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--3C--3D--3E)
【Python】該当なし

####[*](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--2A)
【Ruby】`r * 2 # => "ルビールビー"`
【Python】`p * 2 # => "パイソンパイソン"`

####[+@](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--2B--40)
【Python】該当なし

####[+](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--2B)
【Ruby】`r + p # => "ルビーパイソン"`
【Python】`p + r # => "パイソンルビー"`

####[-@](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--2D--40)
【Python】該当なし

####[===](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--3D--3D)
【Ruby】`r === "ルビー" # => true`
【Python】`p == "パイソン" # => True`

####[==](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--3D--3D)
【Ruby】`r == p # => false`
【Python】`p == r # => False`

####[=~](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--3D--7E)
【Ruby】`r =~ /ビ/ # => 1`
【Python】`re.search(r"ビ", r) # => <re.Match object; span=(1, 2), match="ビ">`
https://docs.python.org/ja/3/library/re.html#re.search

####[[]=](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--5B--5D--3D)
【Python】該当なし


####[[]](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--5B--5D)
【Ruby】`r[0] # => "ル"` `r[0,2] # => "ルビ"` `r[0..1] # => "ルビ"` `r[0...2] # => "ルビ"`
【Python】`r[0] # => "ル"` `r[0:3] # => "ルビ"`

####[ascii_only?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_ASCII_ONLY--3F)
【Ruby】`r.ascii_only? # => false`
【Python】`p.isascii() # => False`
https://docs.python.org/ja/3/library/stdtypes.html#str.isascii

####[b](https://docs.ruby-lang.org/ja/latest/class/String.html#I_B)
【Python】該当なし

####[bytes](https://docs.ruby-lang.org/ja/latest/class/String.html#I_BYTES)
【Ruby】`r.bytes # => [227, 131, 171, 227, 131, 147, 227, 131, 188]`
【Python】`list(r.encode("utf-8")) # => [227, 131, 171, 227, 131, 147, 227, 131, 188]`
https://docs.python.org/ja/3/library/stdtypes.html#list
https://docs.python.org/ja/3/library/stdtypes.html#str.encode

####[bytesize](https://docs.ruby-lang.org/ja/latest/class/String.html#I_BYTESIZE)
【Ruby】`r.bytesize # => 9`
【Python】`len(r.encode("utf-8")) # => 9`

####[byteslice](https://docs.ruby-lang.org/ja/latest/class/String.html#I_BYTESLICE)
【Ruby】`r.byteslice(0) # => "\xE3"` `r.byteslice(0,3) # => "ル"` `r.byteslice(0..2) # => "ル"` `r.byteslice(0...3) # => "ル"`
【Python】`p[0] # => "パ"`

####[capitalize](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CAPITALIZE)
【Ruby】`"rubyPython".capitalize # => "Rubypython"`
【Python】`"rubyPython".capitalize() # => "Rubypython"`
https://docs.python.org/ja/3/library/stdtypes.html#str.capitalize


####[casecmp?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CASECMP--3F)
【Ruby】`"ruby".casecmp?("RUBY") # => true` `"RUBY".casecmp?("ruby") # => true`
【Python】`"python".casefold() == "PYTHON" # => False` `"PYTHON".casefold() == "python" # => True`
https://docs.python.org/ja/3/library/stdtypes.html#str.casefold

####[casecmp](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CASECMP)
【Python】該当なし

####[center](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CENTER)
【Ruby】`r.center(9) # => "：：：ルビー：：："`
【Python】`p.center(9) # => "：：：ルビー：：："`
https://docs.python.org/ja/3/library/stdtypes.html#str.center

####[chars](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CHARS)
【Ruby】`r.chars # => ["ル", "ビ", "ー"]`
【Python】`list(p) # => => ["パ", "イ", "ソ", "ン"]`
https://docs.python.org/ja/3/library/stdtypes.html#list

####[chomp](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CHOMP)
【Ruby】`"ルビー\n".chomp # => "ルビー"`
【Python】`"パイソン\n".rstrip() # => "パイソン"`
https://docs.python.org/ja/3/library/stdtypes.html#str.rstrip

####[chop](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CHOP)
【Ruby】`r.chop # => "ルビ"`
【Python】`p[:-1] # => "パイソ"`
https://docs.python.org/ja/3/reference/expressions.html#slicings

####[chr](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CHR)
【Ruby】`r.chr # => "ル"`
【Python】`p[0] # => "パ"`
https://docs.python.org/ja/3/reference/expressions.html#slicings

####[clear](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CLEAR)
【Ruby】`r.clear # => ""`
【Python】`p = "" # => ""`


####[codepoints](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CODEPOINTS)
【Ruby】`r.codepoints # => [12523, 12499, 12540]`
【Python】`[ord(a) for a in r] # => [12523, 12499, 12540]`
https://docs.python.org/ja/3/library/functions.html#ord

####[concat](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--3C--3C)
【Ruby】`r.concat(12497) # => "ルビーパ"`
【Python】`r += chr(12497) # => "ルビーパ"`
https://docs.python.org/ja/3/library/functions.html#chr

####[count](https://docs.ruby-lang.org/ja/latest/class/String.html#I_COUNT)
【Ruby】`p.count("パン") # => 2`
【Python】`p.count("パン") # => 0`
https://docs.python.org/ja/3/library/stdtypes.html#str.count

####[crypt](https://docs.ruby-lang.org/ja/latest/class/String.html#I_CRYPT)
【Python】該当なし

####[delete](https://docs.ruby-lang.org/ja/latest/class/String.html#I_DELETE)
【Ruby】`p.delete("パソ") # => "イン"`
【Python】`re.sub(r"パ|ソ", "", p) # =>"イン"`
https://docs.python.org/ja/3/library/re.html#re.sub

####[delete_prefix](https://docs.ruby-lang.org/ja/latest/class/String.html#I_DELETE_PREFIX)
【Ruby】`p.delete_prefix("パイ") # => "ソン"`
【Python】`re.sub(r"^パイ", "", p) # => "ソン"`
https://docs.python.org/ja/3/library/re.html#re.sub

####[delete_suffix](https://docs.ruby-lang.org/ja/latest/class/String.html#I_DELETE_SUFFIX)
【Ruby】`r.delete_suffix("ー") # => "ルビ"`
【Python】`re.sub(r"ー$", "", r) # => "ルビ"`
https://docs.python.org/ja/3/library/re.html#re.sub

####[downcase](https://docs.ruby-lang.org/ja/latest/class/String.html#I_DOWNCASE)
【Ruby】`"RUBY".downcase # => "ruby"`
【Python】`"PYTHON".lower() # => "python"`
https://docs.python.org/ja/3/library/stdtypes.html#str.lower

####[dump](https://docs.ruby-lang.org/ja/latest/class/String.html#I_DUMP)
【Python】該当なし


####[each_byte](https://docs.ruby-lang.org/ja/latest/class/String.html#I_EACH_BYTE)
【Ruby】`r.each_byte.map{|b| b} # => [227, 131, 171, 227, 131, 147, 227, 131, 188]`
【Python】`[i for i in r.encode("utf-8")] # => [227, 131, 171, 227, 131, 147, 227, 131, 188]`
https://docs.python.org/ja/3/library/stdtypes.html#str.encode

####[each_char](https://docs.ruby-lang.org/ja/latest/class/String.html#I_EACH_CHAR)
【Ruby】`r.each_char{|c| print "|%s|"%(c)} # => |ル||ビ||ー|`
【Python】`[print("|%s|"%(c), end="") for c in r] # => |ル||ビ||ー|`


####[each_codepoint](https://docs.ruby-lang.org/ja/latest/class/String.html#I_EACH_CODEPOINT)
【Ruby】`r.each_codepoint.to_a # => [12523, 12499, 12540]`
【Python】`[ord(c) for c in r] # => [12523, 12499, 12540]`
https://docs.python.org/ja/3/library/functions.html#ord

####[each_grapheme_cluster](https://docs.ruby-lang.org/ja/latest/class/String.html#I_EACH_GRAPHEME_CLUSTER)
【Python】該当なし


####[each_line](https://docs.ruby-lang.org/ja/latest/class/String.html#I_EACH_LINE)
【Ruby】`"ruby\npython\n".each_line.to_a # => ["ruby\n", "python\n"]`
【Python】`"ruby\npython\n".splitlines(keepends=True) # => ["ruby\n", "python\n"]`
https://docs.python.org/ja/3/library/stdtypes.html#str.splitlines


####[empty?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_EMPTY--3F)
【Ruby】`"".empty? # => true`
【Python】`len("") == 0 # => True`
https://docs.python.org/ja/3/library/functions.html#len

####[encode](https://docs.ruby-lang.org/ja/latest/class/String.html#I_ENCODE)
【Ruby】`r.encode("eucjp") # => "\x{A5EB}\x{A5D3}\x{A1BC}"`
【Python】`r.encode("eucjp") # => "\x{A5EB}\x{A5D3}\x{A1BC}"`
https://docs.python.org/ja/3/library/stdtypes.html#str.encode

####[encoding](https://docs.ruby-lang.org/ja/latest/class/String.html#I_ENCODING)
【Python】該当なし

####[end_with?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_END_WITH--3F)
【Ruby】`r.end_with?("ン") # => false`
【Python】`r.endswith("ン") # => False`
https://docs.python.org/ja/3/library/stdtypes.html#str.endswith

####[eql?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_EQL--3F)
【Ruby】`r.eql?(p) # => false`
【Python】`r == p # => False`

####[force_encoding](https://docs.ruby-lang.org/ja/latest/class/String.html#I_FORCE_ENCODING)
【Python】該当なし

####[getbyte](https://docs.ruby-lang.org/ja/latest/class/String.html#I_GETBYTE)
【Ruby】`r.getbyte(0) # => 227`
【Python】`r.encode("utf-8")[0] # => 227`
https://docs.python.org/ja/3/library/stdtypes.html#str.encode

####[grapheme_clusters](https://docs.ruby-lang.org/ja/latest/class/String.html#I_GRAPHEME_CLUSTERS)
【Python】該当なし

####[gsub](https://docs.ruby-lang.org/ja/latest/class/String.html#I_GSUB)
【Ruby】`p.gsub(/イ|ン/){"ル"} # => "パルソル"`
【Python】`re.sub(r"イ|ン", "ル", p) # => "パルソル"`

####[hash](https://docs.ruby-lang.org/ja/latest/class/String.html#I_HASH)
【Ruby】`r.hash # => 4357911679365031938`
【Python】`hash(r) # => 5233874843298921886`
https://docs.python.org/ja/3/library/functions.html#hash

####[hex](https://docs.ruby-lang.org/ja/latest/class/String.html#I_HEX)
【Ruby】`"EFG".hex # => 239`
【Python】`int("EFG", 16) # => ValueError`

####[include?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_INCLUDE--3F)
【Ruby】`p.include?("パイ") # => true`
【Python】`"パイ" in p # => True`

####[index](https://docs.ruby-lang.org/ja/latest/class/String.html#I_INDEX)
【Ruby】`"rubypython".index("y") # => 3`
【Python】`"rubypython".find("y") # => 3`
https://docs.python.org/ja/3/library/stdtypes.html#str.find

####[insert](https://docs.ruby-lang.org/ja/latest/class/String.html#I_INSERT)
【Python】該当なし

####[inspect](https://docs.ruby-lang.org/ja/latest/class/String.html#I_INSPECT)
【Python】該当なし

####[intern](https://docs.ruby-lang.org/ja/latest/class/String.html#I_INTERN)
【Python】該当なし

####[length](https://docs.ruby-lang.org/ja/latest/class/String.html#I_LENGTH)
【Ruby】`r.length # => 3`
【Python】`len(r) # => 3`
https://docs.python.org/ja/3/library/functions.html#len

####[lines](https://docs.ruby-lang.org/ja/latest/class/String.html#I_LINES)
【Ruby】`"ruby\npython\n".lines # => ["ruby\n", "python\n"]`
【Python】`"ruby\npython\n".splitlines() # => ["ruby", "python"]`
https://docs.python.org/ja/3/library/stdtypes.html#str.splitlines

####[ljust](https://docs.ruby-lang.org/ja/latest/class/String.html#I_LJUST)
【Ruby】`r.ljust(6, "：") # => "ルビー：：："`
【Python】`r.ljust(6, "：") # => "ルビー：：："`
https://docs.python.org/ja/3/library/stdtypes.html#str.ljust

####[lstrip](https://docs.ruby-lang.org/ja/latest/class/String.html#I_LSTRIP)
【Ruby】`"\ruby".lstrip # => "uby"`
【Python】`"\ruby".lstrip() # => "uby"`
https://docs.python.org/ja/3/library/stdtypes.html#str.lstrip

####[match?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_MATCH--3F)
【Ruby】`r.match?(/ビ/) # => true`
【Python】`re.search(r"ビ", r) != None # => True`
https://docs.python.org/ja/3/library/re.html#re.search

####[match](https://docs.ruby-lang.org/ja/latest/class/String.html#I_MATCH)
【Ruby】`p.match(/イ.ン/) # => #<MatchData "イソン">`
【Python】`re.search(r"イ.ン", p) # => <re.Match object; span=(1, 4), match="イソン">`
https://docs.python.org/ja/3/library/re.html#re.search

####[new](https://docs.ruby-lang.org/ja/latest/class/String.html#S_NEW)
【Ruby】`String.new("ruby") # => "ruby"`
【Python】`str("ruby") # => "ruby"`
https://docs.python.org/ja/3/library/stdtypes.html#str

####[next](https://docs.ruby-lang.org/ja/latest/class/String.html#I_NEXT)
【Ruby】`p.next # => "パイソヴ"`
【Python】`p[:-1]+chr(ord(p[-1]) + 1) # => "パイソヴ"`
https://docs.python.org/ja/3/library/functions.html#ord

####[oct](https://docs.ruby-lang.org/ja/latest/class/String.html#I_OCT)
【Ruby】`"10".oct # => 8`
【Python】`int("10", 8) # => 8`
https://docs.python.org/ja/3/library/functions.html#int

####[ord](https://docs.ruby-lang.org/ja/latest/class/String.html#I_ORD)
【Ruby】`r.ord # => 12523`
【Python】`ord(r[0]) # => 12523`
https://docs.python.org/ja/3/library/functions.html#ord

####[partition](https://docs.ruby-lang.org/ja/latest/class/String.html#I_PARTITION)
【Ruby】`"rubypython".partition("y") # => ["rub", "y", "python"]`
【Python】`"rubypython".partition("y") # => ("rub", "y", "python")`
https://docs.python.org/ja/3/library/stdtypes.html#str.partition

####[prepend](https://docs.ruby-lang.org/ja/latest/class/String.html#I_PREPEND)
【Python】該当なし

####[replace](https://docs.ruby-lang.org/ja/latest/class/String.html#I_REPLACE)
【Python】該当なし

####[reverse](https://docs.ruby-lang.org/ja/latest/class/String.html#I_REVERSE)
【Ruby】`p.reverse # => "ンソイパ"`
【Python】`p[::-1] # => "ンソイパ"`

####[rindex](https://docs.ruby-lang.org/ja/latest/class/String.html#I_RINDEX)
【Ruby】`"rubypython".rindex("y") # => 5`
【Python】`"rubypython".rfind("y") # => 5`
https://docs.python.org/ja/3/library/stdtypes.html#str.rfind

####[rjust](https://docs.ruby-lang.org/ja/latest/class/String.html#I_RJUST)
【Ruby】`r.rjust(6, "：") # => "：：：ルビー"`
【Python】`r.rjust(6, "：") # => "：：：ルビー"`
https://docs.python.org/ja/3/library/stdtypes.html#str.rjust

####[rpartition](https://docs.ruby-lang.org/ja/latest/class/String.html#I_RPARTITION)
【Ruby】`"rubypython".rpartition("y") # => ["rubyp", "y", "thon"]`
【Python】`"rubypython".rpartition("y") # => ("rubyp", "y", "thon")`
https://docs.python.org/ja/3/library/stdtypes.html#str.rpartition

####[rstrip](https://docs.ruby-lang.org/ja/latest/class/String.html#I_RSTRIP)
【Ruby】`"pytho\n".rstrip # => "pytho"`
【Python】`"pytho\n".rstrip() # => "pytho"`
https://docs.python.org/ja/3/library/stdtypes.html#str.rstrip

####[scan](https://docs.ruby-lang.org/ja/latest/class/String.html#I_SCAN)
【Ruby】`"rubypython".scan(/(.y)/) # => [["by"], ["py"]]`
【Python】`re.findall(r"(.y)", "rubypython") # => ["by", "py"]`
https://docs.python.org/ja/3/library/re.html#re.findall

####[scrub](https://docs.ruby-lang.org/ja/latest/class/String.html#I_SCRUB)
【Ruby】`"\u30eb\u30d3\u30fc\xff".scrub # => "ルビー�"`
【Python】`b"\u30eb\u30d3\u30fc\xff".decode("utf-8","replace") # =>
\u30eb\u30d3\u30fc�`
https://docs.python.org/ja/3/library/stdtypes.html#bytes.decode

####[setbyte](https://docs.ruby-lang.org/ja/latest/class/String.html#I_SETBYTE)
【Python】該当なし

####[size](https://docs.ruby-lang.org/ja/latest/class/String.html#I_LENGTH)
【Ruby】`r.size # => 3`
【Python】`len(r) # => 3`
https://docs.python.org/ja/3/library/functions.html#len

####[slice](https://docs.ruby-lang.org/ja/latest/class/String.html#I_--5B--5D)
【Ruby】`r.slice(1) == ?ビ # => true`
【Python】`r[1] == "ビ" # => True`
https://docs.python.org/ja/3/reference/expressions.html#subscriptions

####[split](https://docs.ruby-lang.org/ja/latest/class/String.html#I_SPLIT)
【Ruby】`"ルビーとパイソン".split(/と/) # => ["ルビー", "パイソン"]`
【Python】`"ルビーとパイソン".split("と") # => ["ルビー", "パイソン"]`
https://docs.python.org/ja/3/library/stdtypes.html#str.split

####[squeeze](https://docs.ruby-lang.org/ja/latest/class/String.html#I_SQUEEZE)
【Python】該当なし

####[start_with?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_START_WITH--3F)
【Ruby】`p.start_with?("ル", "パ", "ン") # => true`
【Python】`p.startswith(("ル", "パ", "ン")) # => True`
https://docs.python.org/ja/3/library/stdtypes.html#str.startswith

####[strip](https://docs.ruby-lang.org/ja/latest/class/String.html#I_STRIP)
【Ruby】`"\ruby pytho\n".strip => "uby pytho"`
【Python】`"\ruby pytho\n".strip() # => "uby pytho"`
https://docs.python.org/ja/3/library/stdtypes.html#str.strip

####[sub](https://docs.ruby-lang.org/ja/latest/class/String.html#I_SUB)
【Ruby】`"ruby python".sub(/y/){"ied"} # => "rubied python"`
【Python】`"ruby python".replace("y", "ied", 1) # => "rubied python"`
https://docs.python.org/ja/3/library/stdtypes.html#str.replace

####[succ](https://docs.ruby-lang.org/ja/latest/class/String.html#I_NEXT)
【Ruby】`"1.9.9".succ # => "2.0.0"`
【Python】`"1.9.9"[:-1]+str(int("1.9.9"[-1])+1) # => "1.9.10"`
https://docs.python.org/ja/3/library/functions.html#int

####[sum](https://docs.ruby-lang.org/ja/latest/class/String.html#I_SUM)
【Python】該当なし

####[swapcase](https://docs.ruby-lang.org/ja/latest/class/String.html#I_SWAPCASE)
【Ruby】`"Ruby Python".swapcase # => "rUBY pYTHON"`
【Python】`"Ruby Python".swapcase() # => "rUBY pYTHON"`
https://docs.python.org/ja/3/library/stdtypes.html#str.swapcase

####[to_c](https://docs.ruby-lang.org/ja/latest/class/String.html#I_TO_C)
【Ruby】`"12+3i".to_c # => (12+3i)`
【Python】`complex("12+3j") # =>(12+3j)`
https://docs.python.org/ja/3/library/functions.html#complex

####[to_f](https://docs.ruby-lang.org/ja/latest/class/String.html#I_TO_F)
【Ruby】`"2.7".to_f # => 2.7`
【Python】`float("2.7").to_f # => 2.7`
https://docs.python.org/ja/3/library/functions.html#float

####[to_i](https://docs.ruby-lang.org/ja/latest/class/String.html#I_TO_I)
【Ruby】`"3.8.2".to_i # => 3`
【Python】`int("3.8.2") # => ValueError`
https://docs.python.org/ja/3/library/functions.html#int

####[to_r](https://docs.ruby-lang.org/ja/latest/class/String.html#I_TO_R)
【Ruby】`"2/6".to_r # => (1/3)`
【Python】`fractions.fraction("2/6") # => Fraction(1, 3)`
https://docs.python.org/ja/3/library/fractions.html#module-fractions

####[to_s](https://docs.ruby-lang.org/ja/latest/class/String.html#I_TO_S)
【Ruby】`nil.to_s # => ""`
【Python】`str(None) # => "None"`
https://docs.python.org/ja/3/library/functions.html#func-str

####[to_str](https://docs.ruby-lang.org/ja/latest/class/String.html#I_TO_S)
【Ruby】`r.to_s # => "ルビー"`
【Python】`str(r) # => "ルビー"`
https://docs.python.org/ja/3/library/functions.html#func-str

####[to_sym](https://docs.ruby-lang.org/ja/latest/class/String.html#I_INTERN)
【Python】該当なし

####[tr](https://docs.ruby-lang.org/ja/latest/class/String.html#I_TR)
【Ruby】`"ruby python".tr("a-z", "A-Z") # => "RUBY PYTHON"`
【Python】`"ruby python".translate(str.maketrans(string.ascii_lowercase, string.ascii_uppercase)) # => "RUBY PYTHON"`
https://docs.python.org/ja/3/library/stdtypes.html#str.translate

####[tr_s](https://docs.ruby-lang.org/ja/latest/class/String.html#I_TR_S)
【Python】該当なし

####[try_convert](https://docs.ruby-lang.org/ja/latest/class/String.html#S_TRY_CONVERT)
【Ruby】`String.try_convert(2.7) # => nil`
【Python】`str(3.8) # => "3.8"`
https://docs.python.org/ja/3/library/functions.html#func-str

####[undump](https://docs.ruby-lang.org/ja/latest/class/String.html#I_UNDUMP)
【Python】該当なし

####[unicode_normalize](https://docs.ruby-lang.org/ja/latest/class/String.html#I_UNICODE_NORMALIZE)
【Ruby】`"#{r}と#{p}".unicode_normalize(:nfd).chars # => ["ル", "ヒ", "゙", "ー", "と", "ハ", "゚", "イ", "ソ", "ン"]`
【Python】`[c for c in unicodedata.normalize("NFD", f"{r}と{p}")] # => ["ル", "ヒ", '゙", "ー", "と", "ハ", '゚", "イ", "ソ", "ン"]`
https://docs.python.org/ja/3/library/unicodedata.html#unicodedata.normalize

####[unicode_normalized?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_UNICODE_NORMALIZED--3F)
【Ruby】`"#{r}と#{p}".unicode_normalized?(:nfd) # => false`
【Python】`unicodedata.is_normalized("NFD", f"{r}と{p}") # => False`
https://docs.python.org/ja/3/library/unicodedata.html#unicodedata.is_normalized

####[unpack1](https://docs.ruby-lang.org/ja/latest/class/String.html#I_UNPACK1)
【Python】該当なし

####[unpack](https://docs.ruby-lang.org/ja/latest/class/String.html#I_UNPACK)
【Python】該当なし

####[upcase](https://docs.ruby-lang.org/ja/latest/class/String.html#I_UPCASE)
【Ruby】`"ruby python".upcase # => "RUBY PYTHON"`
【Python】`"ruby python".upper() # => "RUBY PYTHON"`
https://docs.python.org/ja/3/library/stdtypes.html#str.upper

####[upto](https://docs.ruby-lang.org/ja/latest/class/String.html#I_UPTO)
【Ruby】`"p".upto("r").to_a # => ["p", "q", "r"]`
【Python】`[chr(c) for c in range(ord("p"), ord("r")+1)]
["p", "q", "r"]`
https://docs.python.org/ja/3/library/functions.html#chr

####[valid_encoding?](https://docs.ruby-lang.org/ja/latest/class/String.html#I_VALID_ENCODING--3F)
【Python】該当なし

#補足
Ruby 2.7、Python 3.8 をベースにしてます。
https://docs.ruby-lang.org/ja/latest/class/String.html
https://docs.python.org/ja/3/library/stdtypes.html#textseq

- `!`（破壊的変更）の対応は省略してます（ Python の string クラスはイミュータブルの為）。
- `【Python】該当なし`は**できない**を意味しません（数個の関数、メソッドの組み合わせでできる翻訳が思いつかないだけです）。
- Ruby と Python では設計思想が違うので**厳密に同じ**ではありません。
- Python の対応ドキュメントのリンクをできるだけ記載してますが見つからないのが（特に演算子）多々あります。
- 標準ライブラリ・モジュールのみを前提にしてます。

#あとがき
コーディングで ruby ではすぐ思いつくけど、python ではどう書く？という人（私）向けです。
網羅性を主眼としてます。そのため使ったことのない、使い道のわからないメソッドもそこそこありました。
同じアルゴリズム・ロジックを実現するのに、ruby はフルコース、python はア・ラ・カルト、が感想
多LGTMの為だけに、タイトルを『Rubyist が Python なんて大したことないね、とディスりつつこっそり見るチートシート』的なものにする誘惑に駆られた。（でも公式ガイドラインに準拠した）
他に配列クラス（Array→list）、辞書クラス（Hash→dict）のチートシートがあれば、とりあえずよいかな？（共同編集できればよいのだが）
 ~~右端にインデックスが全部掲示されない．．．~~ （スクロールできたのか）

#参考
[Qiita記事検索](https://qiita.com/search?q=title%3Aruby+title%3Apython)
[RubyistのためのPython入門](https://qiita.com/yosu/items/46968c21fe8d21c60185)
[Python と Ruby の比較（環境・文法・リテラル編）](https://qiita.com/sho-hata/items/f70e398629d4c4307f9c)
[rubyとpythonの基本的なやつ対応表メモ](https://qiita.com/nekozestrtgy/items/d6ebda7ebc89d958ce56)
[ruby でこう書くのは、python ならこう書く、のメモ](https://qiita.com/Nabetani/items/50b0f6533a15d8fb2ae5)