Python مجموعهای از روشهای داخلی دارد که میتوانید روی رشتهها استفاده کنید.
مثال
The strip() method removes any whitespace from the beginning or the end:
a = " Hello, World! "
print(a.strip()) # returns "Hello, World!"
مثال
The lower() method returns the string in lower case:
a = "Hello, World!"
print(a.lower())
مثال
The upper() method returns the string in upper case:
a = "Hello, World!"
print(a.upper())
مثال
The replace() method replaces a string with another string:
a = "Hello, World!"
print(a.replace("H", "J"))
مثال
The split() method splits the string into substrings if it finds instances of the separator:
a = "Hello, World!"
print(a.split(",")) #
returns ['Hello', ' World!']
درباره روشهای رشتهای با مرجع روشهای رشتهای
ما بیشتر بیاموزید