Python str() Fungsi
Contoh
Ubah angka 3.5 menjadi string:
x =
str(3.5)
Definisi dan Penggunaan
Fungsi str()
mengubah nilai yang ditentukan menjadi string.
Sintaksis
str(object, encoding=encoding, errors=errors)
Nilai Parameter
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 |
Lebih Banyak Contoh
Contoh
Mengubah string menjadi bilangan bulat:
x =
int("12")