Python str()関数
例
数値3.5を文字列に変換します。
x =
str(3.5)
定義と使用法
このstr()
関数は、指定された値を文字列に変換します。
構文
str(object, encoding=encoding, errors=errors)
パラメータ値
Parameter | Description |
---|---|
object | Any object. Specifies the object to convert into a string |
encoding | The encoding of the object. Default is UTF-8 |
errors | Specifies what to do if the decoding fails |
その他の例
例
文字列を整数に変換します。
x =
int("12")