Python là ký tự trong chuỗi

Chương trình Python để kiểm tra một chuỗi cho các ký tự cụ thể

Cải thiện bài viết

Lưu bài viết

Thích bài viết

  • Cập nhật lần cuối. 06 tháng 1 năm 2023

  • Đọc
  • Bàn luận
  • khóa học
  • Luyện tập
  • Băng hình
  • Cải thiện bài viết

    Lưu bài viết

    Tại đây,  sẽ kiểm tra một chuỗi cho một ký tự cụ thể bằng các phương thức khác nhau bằng Python. Trong ví dụ dưới đây, một chuỗi 's' và mảng char 'arr', nhiệm vụ là viết một chương trình python để kiểm tra chuỗi s cho các ký tự trong mảng char arr

    ví dụ

    Đầu vào. s = @geekforgeek%
    mảng[] = {'o','e','%'}
    đầu ra. [đúng, đúng, đúng]

    Đầu vào. s = $ đam mê
    mảng[] = {'@','e','a','$'}
    đầu ra. [sai, đúng, sai, đúng]

    Phương pháp 1. Kiểm tra một chuỗi cho một ký tự cụ thể bằng cách sử dụng trong từ khóa + vòng lặp

    Duyệt qua mảng char và kiểm tra từng ký tự trong mảng xem ký tự đó có trong chuỗi s hay không bằng cách sử dụng toán tử trả về giá trị boolean [Đúng hoặc sai]

    Python3




    # function to check string

    def check[s, arr]:

        

    [True, True, True, True, False]
    0
    [True, True, True, True, False]
    1
    [True, True, True, True, False]
    2

        

    [True, True, True, True, False]
    4
    [True, True, True, True, False]
    5
    [True, True, True, True, False]
    6
    [True, True, True, True, False]
    7

    [True, True, True, True, False]
    8

    [True, True, True, True, False]
    9
    [True, True, True]
    0

    [True, True, True, True, False]
    9
    [True, True, True]
    2

    [True, True, True, True, False]
    9
    [True, True, True]
    4
    [True, True, True, True, False]
    5
    [True, True, True, True, False]
    6
    [True, True, True]
    7

    [True, True, True]
    8
    [True, True, True]
    9
    Character not found
    0
    Character not found
    1

    [True, True, True, True, False]
    9
    Character not found
    3
    Character not found
    4

    [True, True, True]
    8
    [True, True, True]
    9
    Character not found
    7
    Character not found
    1

        

    [True, True, True, True, False]
    0
    [True, True, True, True, False]
    0

     

     

    [True, True, True, True, False]
    2

    [True, True, True, True, False]
    3
    [True, True, True, True, False]
    1
    [True, True, True, True, False]
    5

    [True, True, True, True, False]
    6_______0_______1
    [True, True, True, True, False]
    8
    [True, True, True, True, False]
    9
    [True, True, True]
    0
    [True, True, True]
    1
    [True, True, True]
    0
    [True, True, True]
    3
    [True, True, True]
    0    1
    [True, True, True]
    0    3
    [True, True, True]
    6

    Chuỗi là một cấu trúc dữ liệu trong Python đại diện cho một chuỗi ký tự. Nó là kiểu dữ liệu không thể thay đổi, nghĩa là khi bạn đã tạo một chuỗi thì bạn không thể thay đổi nó. Chuỗi được sử dụng rộng rãi trong nhiều ứng dụng khác nhau, chẳng hạn như lưu trữ và thao tác dữ liệu văn bản, biểu diễn tên, địa chỉ và các loại dữ liệu khác có thể được biểu diễn dưới dạng văn bản

    Thí dụ

    "Geeksforgeeks" or 'Geeksforgeeks'

    Python không có kiểu dữ liệu ký tự, một ký tự đơn giản chỉ là một chuỗi có độ dài là 1. Dấu ngoặc vuông có thể được sử dụng để truy cập các phần tử của chuỗi

    Python3




    A Computer Science portal for geeks
    4_______46_______5
    A Computer Science portal for geeks
    6
    A Computer Science portal for geeks
    7

    đầu ra

    A Computer Science portal for geeks

    Tạo chuỗi trong Python

    Các chuỗi trong Python có thể được tạo bằng cách sử dụng dấu ngoặc đơn hoặc dấu ngoặc kép hoặc thậm chí là dấu ngoặc kép.  

    Python3




    A Computer Science portal for geeks
    8

    A Computer Science portal for geeks
    9

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    0

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    1

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    4

    A Computer Science portal for geeks
    4_______46_______5
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    7
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    0

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    2

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2____53_______3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    5

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    8
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    0

    skeegrofskeeg
    3

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    skeegrofskeeg
    6

    A Computer Science portal for geeks
    4_______46_______5
    skeegrofskeeg
    9
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    skeegrofskeeg
    3

    skeegrofskeeg
    4

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2____53_______3
    skeegrofskeeg
    7

    skeegrofskeeg
    8
    skeegrofskeeg
    9

    skeegrofskeeg
    8
    Initial String: 
    GeeksForGeeks
    
    Slicing characters from 3-12: 
    ksForGeek
    
    Slicing characters between 3rd and 2nd last character: 
    ksForGee
    1

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    Slicing characters from 3-12: 
    ksForGeek
    
    Slicing characters between 3rd and 2nd last character: 
    ksForGee
    4
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

    đầu ra.  

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life

    Truy cập các ký tự trong Chuỗi Python

    Trong Python, có thể truy cập các ký tự riêng lẻ của Chuỗi bằng cách sử dụng phương thức Lập chỉ mục. Lập chỉ mục cho phép các tham chiếu địa chỉ phủ định truy cập các ký tự từ phía sau Chuỗi, e. g. -1 đề cập đến ký tự cuối cùng, -2 đề cập đến ký tự cuối cùng thứ hai, v.v.  

    Khi truy cập một chỉ mục ngoài phạm vi sẽ gây ra lỗi IndexError. Chỉ các Số nguyên mới được phép chuyển dưới dạng chỉ mục, số float hoặc các loại khác sẽ gây ra TypeError

     


    Python3




    Initial String: 
    GeeksForGeeks
    
    Slicing characters from 3-12: 
    ksForGeek
    
    Slicing characters between 3rd and 2nd last character: 
    ksForGee
    8

    Initial String: 
    GeeksForGeeks
    
    Slicing characters from 3-12: 
    ksForGeek
    
    Slicing characters between 3rd and 2nd last character: 
    ksForGee
    9

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    2

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    5
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    9

    A Computer Science portal for geeks
    4_______46_______5
    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    2
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______116_______5
    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    6
    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    7

     

    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    8

    A Computer Science portal for geeks
    4_______46_______5
    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    1
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______116_______5
    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    5
    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    6
    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    7

    đầu ra.  

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s

    Đảo ngược chuỗi Python

    Với Truy cập các ký tự từ một chuỗi, chúng ta cũng có thể đảo ngược chúng. Chúng ta có thể Đảo ngược một chuỗi bằng cách viết [. -1] và chuỗi sẽ bị đảo ngược

    Python3




    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    8

    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    9____53_______3
    A Computer Science portal for geeks
    01

    A Computer Science portal for geeks
    4_______46_______03
    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    5
    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    6
    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    7

    đầu ra

    skeegrofskeeg

    Chúng ta cũng có thể đảo ngược một chuỗi bằng cách sử dụng hàm nối và đảo ngược tích hợp

    Python3




    A Computer Science portal for geeks
    07

     

    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    9____53_______3
    A Computer Science portal for geeks
    01

     

    A Computer Science portal for geeks
    11

    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    9
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    A Computer Science portal for geeks
    14
    A Computer Science portal for geeks
    15
    A Computer Science portal for geeks
    16

     

    A Computer Science portal for geeks
    4_______46_______18

    đầu ra

    skeegrofskeeg

    cắt chuỗi

    Để truy cập một dãy ký tự trong String, phương pháp cắt lát được sử dụng. Việc cắt trong Chuỗi được thực hiện bằng cách sử dụng toán tử Cắt [dấu hai chấm].  

    Python3




    A Computer Science portal for geeks
    19

    A Computer Science portal for geeks
    20

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    0

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    2

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    5
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    A Computer Science portal for geeks
    31

    A Computer Science portal for geeks
    4_______46_______5
    A Computer Science portal for geeks
    34
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______116_______5
    A Computer Science portal for geeks
    38
    A Computer Science portal for geeks
    39
    A Computer Science portal for geeks
    40
    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    7

     

    A Computer Science portal for geeks
    42

    A Computer Science portal for geeks
    43

    A Computer Science portal for geeks
    4_______46_______5
    A Computer Science portal for geeks
    46
    A Computer Science portal for geeks
    47

    A Computer Science portal for geeks
    48
    A Computer Science portal for geeks
    49
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______116_______5
    A Computer Science portal for geeks
    38
    A Computer Science portal for geeks
    39
    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    5
    A Computer Science portal for geeks
    56
    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    7

    đầu ra.  

    Initial String: 
    GeeksForGeeks
    
    Slicing characters from 3-12: 
    ksForGeek
    
    Slicing characters between 3rd and 2nd last character: 
    ksForGee

    Xóa/Cập nhật từ Chuỗi

    Trong Python, không được phép cập nhật hoặc xóa các ký tự khỏi Chuỗi. Điều này sẽ gây ra lỗi vì không hỗ trợ gán mục hoặc xóa mục khỏi Chuỗi. Mặc dù có thể xóa toàn bộ Chuỗi bằng cách sử dụng từ khóa del tích hợp. Điều này là do Chuỗi là bất biến, do đó các phần tử của Chuỗi không thể thay đổi sau khi được gán. Chỉ các chuỗi mới có thể được gán lại cho cùng một tên.  

    Cập nhật nhân vật.  

    Python3




    A Computer Science portal for geeks
    58

    A Computer Science portal for geeks
    59

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    A Computer Science portal for geeks
    62

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    5
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    A Computer Science portal for geeks
    69

    A Computer Science portal for geeks
    70

    A Computer Science portal for geeks
    71

    A Computer Science portal for geeks
    72

    A Computer Science portal for geeks
    73_______53_______3
    A Computer Science portal for geeks
    75
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    0

    A Computer Science portal for geeks
    77_______46_______56____46_______79
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    A Computer Science portal for geeks
    81

    A Computer Science portal for geeks
    82____53_______3
    A Computer Science portal for geeks
    84

    A Computer Science portal for geeks
    4_______46_______5
    A Computer Science portal for geeks
    87
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______46_______90

     

    A Computer Science portal for geeks
    91

    A Computer Science portal for geeks
    92_______53_______3
    A Computer Science portal for geeks
    94
    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks
    6
    A Computer Science portal for geeks
    39
    A Computer Science portal for geeks
    56
    A Computer Science portal for geeks
    79
    A Computer Science portal for geeks
    47
    A Computer Science portal for geeks
    81
    A Computer Science portal for geeks
    47
    A Computer Science portal for geeks
    94
    A Computer Science portal for geeks
    38
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    04

    A Computer Science portal for geeks
    4_______53_______06

    Lỗi.  

    Traceback [cuộc gọi gần đây nhất cuối cùng].  
    Tập tin “/home/360bb1830c83a918fc78aa8979195653. py”, dòng 10, trong
    Chuỗi1[2] = 'p'
    LoạiLỗi. Đối tượng 'str' không hỗ trợ gán mục

    Cập nhật toàn bộ chuỗi

    Python3




    A Computer Science portal for geeks
    58

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    08

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    A Computer Science portal for geeks
    62

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    5
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    18

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    21

    A Computer Science portal for geeks
    4_______46_______5
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    24
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

    đầu ra.  

    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 

    Xóa một ký tự.  

    Python3




    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    28

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    29

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    A Computer Science portal for geeks
    62

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    5
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    39

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    40

    A Computer Science portal for geeks
    82
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    A Computer Science portal for geeks
    94_______116_______6
    A Computer Science portal for geeks
    39
    A Computer Science portal for geeks
    56
    A Computer Science portal for geeks
    79_______46_______47
    A Computer Science portal for geeks
    94
    A Computer Science portal for geeks
    38
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    04

    A Computer Science portal for geeks
    4_______46_______5
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    54
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______46_______90

    Lỗi.  

    Chuỗi ban đầu.  
    Xin chào, tôi là một Geek

    Xóa ký tự ở chỉ mục thứ 2.  
    Trợ giúp, tôi là một Geek

    Xóa toàn bộ chuỗi

    Có thể xóa toàn bộ chuỗi bằng cách sử dụng từ khóa del. Hơn nữa, nếu chúng ta cố in chuỗi, điều này sẽ tạo ra lỗi vì Chuỗi đã bị xóa và không thể in được.   

    Python3




    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    28

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    08

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    A Computer Science portal for geeks
    62

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    Hello, I'm a Geek
    
    Updated String: 
    Welcome to the Geek World 
    5
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    69

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    70

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    71
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2

    A Computer Science portal for geeks
    4_______46_______5
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    75
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

    Lỗi.  

    Traceback [cuộc gọi gần đây nhất cuối cùng].  
    Tập tin “/home/e4b8f2170f140da99d2fe57d9d8c6a94. py”, dòng 12, trong
    in [Chuỗi1]
    TênLỗi. tên 'String1' không được xác định

    Trình tự thoát trong Python

    Trong khi in Chuỗi có dấu ngoặc đơn và dấu ngoặc kép, nó gây ra Lỗi cú pháp vì Chuỗi đã chứa Dấu ngoặc đơn và Dấu ngoặc kép và do đó không thể in được bằng cách sử dụng một trong hai dấu ngoặc kép này. Do đó, để in một Chuỗi như vậy, hãy sử dụng Dấu ngoặc kép hoặc chuỗi Escape được sử dụng để in các Chuỗi đó.  

    Chuỗi thoát bắt đầu bằng dấu gạch chéo ngược và có thể được hiểu theo cách khác. Nếu các dấu ngoặc đơn được sử dụng để biểu diễn một chuỗi, thì tất cả các dấu nháy đơn có trong chuỗi phải được thoát và điều tương tự cũng được thực hiện đối với Dấu ngoặc kép.  

    Python3




    A Computer Science portal for geeks
    8

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    80

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    81

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    82

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    85

    A Computer Science portal for geeks
    4_______46_______5
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    88
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    92

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    95

    A Computer Science portal for geeks
    4_______46_______5
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    98
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    02

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2____53_______3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    05

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    08
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    12

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    13

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    16

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    19
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    12

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    24

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    27

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    30
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    12

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    35

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    38

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    41
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

    đầu ra

    Initial String with use of Triple Quotes: 
    I'm a "Geek"
    Escaping Single Quote: 
    I'm a "Geek"
    Escaping Double Quotes: 
    I'm a "Geek"
    Escaping Backslashes: 
    C:\Python\Geeks\
    Tab: 
    Hi Geeks
    New Line: 
    Python
    Geeks

    Để bỏ qua các chuỗi thoát trong Chuỗi, r hoặc R được sử dụng, điều này ngụ ý rằng chuỗi là một chuỗi thô và các chuỗi thoát bên trong nó sẽ bị bỏ qua

    Python3




    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    45

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    48

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    51
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    55

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    56

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    59
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    60

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    63
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    67

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    70

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    73
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    55

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    56

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    59
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    70

    A Computer Science portal for geeks
    4_______46_______5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    85
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

    đầu ra

    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58

    Định dạng chuỗi

    Các chuỗi trong Python có thể được định dạng bằng cách sử dụng phương thức format[], đây là một công cụ rất linh hoạt và mạnh mẽ để định dạng Chuỗi. Phương thức định dạng trong Chuỗi chứa dấu ngoặc nhọn {} làm trình giữ chỗ có thể giữ đối số theo vị trí hoặc từ khóa để chỉ định thứ tự

    Python3




    A Computer Science portal for geeks
    8

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    90

     

    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    91

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    94
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    95_______63_______96
    A Computer Science portal for geeks
    5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    98
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    99
    skeegrofskeeg
    00
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    99
    skeegrofskeeg
    02
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______46_______5
    skeegrofskeeg
    06
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    skeegrofskeeg
    10

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    skeegrofskeeg
    13_______63_______95
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    96
    A Computer Science portal for geeks
    5
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    98
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    99
    skeegrofskeeg
    00
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    99
    skeegrofskeeg
    02
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______46_______5
    skeegrofskeeg
    25
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    skeegrofskeeg
    29

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    skeegrofskeeg
    32
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    95
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    96
    skeegrofskeeg
    35
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    98
    skeegrofskeeg
    38
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    skeegrofskeeg
    00
    skeegrofskeeg
    41
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    skeegrofskeeg
    02_______46_______7

    A Computer Science portal for geeks
    4_______46_______5
    skeegrofskeeg
    47
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

    đầu ra.  

    A Computer Science portal for geeks
    0

    Các số nguyên như nhị phân, thập lục phân, v.v. và số float có thể được làm tròn hoặc hiển thị ở dạng số mũ bằng cách sử dụng định dạng định dạng.  

    Python3




    skeegrofskeeg
    51

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    skeegrofskeeg
    54_______63_______95
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    96
    A Computer Science portal for geeks
    5
    skeegrofskeeg
    58
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______46_______5
    skeegrofskeeg
    62
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    skeegrofskeeg
    66

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    skeegrofskeeg
    69_______63_______95
    Initial String: 
    GeeksForGeeks
    
    First character of String is: 
    G
    
    Last cha racter of String is: 
    s
    96
    A Computer Science portal for geeks
    5
    skeegrofskeeg
    73
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______46_______5
    skeegrofskeeg
    77
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

     

    skeegrofskeeg
    81

    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    2
    String with the use of Single Quotes: 
    Welcome to the Geeks World
    
    String with the use of Double Quotes: 
    I'm a Geek
    
    String with the use of Triple Quotes: 
    I'm a Geek and I live in a world of "Geeks"
    
    Creating a multiline String: 
    Geeks
                For
                Life
    3
    skeegrofskeeg
    84_______63_______95_______63_______96
    A Computer Science portal for geeks
    5
    Printing in Octal with the use of Escape Sequences: 
    Hello
    Printing Raw String in Octal Format: 
    This is \110\145\154\154\157
    Printing in HEX with the use of Escape Sequences: 
    This is Geeks in HEX
    Printing Raw String in HEX Format: 
    This is \x47\x65\x65\x6b\x73 in \x48\x45\x58
    6
    skeegrofskeeg
    89
    skeegrofskeeg
    90
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______46_______5
    skeegrofskeeg
    94
    A Computer Science portal for geeks
    7

    A Computer Science portal for geeks
    4_______63_______0

    đầu ra.  

    A Computer Science portal for geeks
    1

    Một chuỗi có thể được căn trái[] hoặc căn giữa[^] bằng cách sử dụng các chỉ định định dạng, được phân tách bằng dấu hai chấm[. ].   

    Có ký tự nào trong chuỗi Python không?

    Chuỗi là Mảng . Dấu ngoặc vuông có thể được sử dụng để truy cập các phần tử của chuỗi. Python does not have a character data type, a single character is simply a string with a length of 1. Square brackets can be used to access elements of the string.

    %s %i trong Python là gì?

    %s cụ thể là được sử dụng để thực hiện nối các chuỗi lại với nhau . Nó cho phép chúng ta định dạng một giá trị bên trong một chuỗi. Nó được sử dụng để kết hợp một chuỗi khác trong một chuỗi. Nó tự động cung cấp chuyển đổi kiểu từ giá trị thành chuỗi.

    Chủ Đề