freeCodeCamp/guide/arabic/python/data-structures/strings/index.md

1.5 KiB

title localeTitle
The Python Strings سلاسل بايثون

يسمح Python str كائنات str أو سلاسل الأحرف بعدة طرق مختلفة:

  • علامات التنصيص المفردة: 'Single quote strings can have "double" quotes inside.' الاقتباس الأحادية على علامات 'Single quote strings can have "double" quotes inside.'

  • علامات الاقتباس المزدوجة: "Double quote strings can have 'single' quotes inside." الاقتباس المزدوجة على علامات "Double quote strings can have 'single' quotes inside."

  • الثلاثي المقتبس:

    `"""Triple quoted strings can span multiple lines. Unescaped "double" and 'single' quotes in triple quoted strings are retained."""

    '''Triple quoted strings can be 'single'or "double" quotes. Unescaped newlines are also retained.''' `

  • غير قابل للتغيير: لا يمكنك تحرير / تغيير سلسلة Python مباشرة بعد إنشائها. على سبيل المثال ، إذا حاولت إعادة تعيين / تغيير الحرف الأول مباشرةً في سلسلة ، فسيتم طرح خطأ.

    `>>> foo = "my string"

    foo[0] = "a" Traceback (most recent call last): File "", line 1, in TypeError: 'str' object does not support item assignment `

مرجع:

نوع تسلسل النص str