LoginSignup
0
0

More than 1 year has passed since last update.

python初学者の備忘録 文字列型の関数について

Last updated at Posted at 2021-09-29

←目次へ

python,Qiita初心者なので、備忘録として記載していきます。 なにせ初心者なので、知識不足はご理解ください。 知識を深めながら追記していきたいと思います。

文字列型で使用する関数

基本

  • str()関数:引数を文字列に変換する
  • len()関数:文字長を返す
  • max()関数:最大値を返す
  • min()関数:最小値を返す
  • format()関数:指定した書式の文字列を返す

str()関数:引数を文字列に変換する

>>> str(1)
'1'
>>> str(3.14)
'3.14'
>>> str(True)
'True'

len()関数:文字長を返す

>>> len('English')
7

max()関数:最大値を返す

>>> max('English') 
's'

min()関数:最小値を返す

>>> min('English')
'E'

format()関数:指定した書式の文字列を返す

format(値, 書式指定文字列) ※formatについては別項でも説明

>>> format(255, '04x')
'00ff'
0
0
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
0