دالة 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")