rfind を使うと、指定した文字が最後に現れる場所(インデックス)を取得することができる。
例
str1 = "12345abab" result = str1.rfind("ab") print(result)
結果
7
雑記
投稿日:
rfind を使うと、指定した文字が最後に現れる場所(インデックス)を取得することができる。
str1 = "12345abab" result = str1.rfind("ab") print(result)
7
執筆者:seyanen
関連記事
xcolor パッケージを使っておく。rowcolor で指定する。 例 \usepackage[table]{xcolor} \begin{document} \begin{table} \begi …
list をrange を指定して初期化すれば良い。数を1つ飛ばしのリストも次のようにして作れる。 例 list1 = list(range(1,10,2)) print(list1) 結果 [1, …
plt.xlabel と plt.ylabel を使う。 例 import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。