0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pythonの文字列メソッド

Posted at

#pythonの文字列メソッド

## 対象の変数
str = 'My name is hoge. Nice to meet you guys'

# 前から何番前に指定した文字列があるか
print(str.find('hoge'))

# 後ろから何番目に指定した文字列があるか指定している
print(str.find('guys'))

# 指定した文字列が何回出現したか
print(str.count('hoge'))

# 先頭の文字列を大文字に変換
print(str.capitalize())

# 単語の先頭の文字を大文字に変換する
print(str.title())

# 単語をすべて小文字に
print(str.lower())

# 単語をすべて大文字に
print(str.upper())

# 大文字は小文字 小文字は大文字に変換
print(str.swapcase())

# すべての文字が大文字が判定
print(str.isupper())

# すべての文字が小文字が判定
print(str.islower())

参考にした記事
pythonにおける文字列操作
python文字列メソッド一覧

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?