Sự khác biệt giữa chuỗi và ký tự trong python

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

Ví 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_______1_______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_______1_______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_______18_______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
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
5

A Computer Science portal for geeks
4_______1_______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_______18_______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_______1_______5
skeegrofskeeg
9
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4_______18_______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
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
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_______1_______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_______18_______0

đầu ra.  

________số 8_______

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

Sự khác biệt giữa chuỗi và ký tự trong python

 


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_______1_______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_______18_______0

 

Initial String: 
Hello, I'm a Geek

Updated String: 
Welcome to the Geek World 
9

A Computer Science portal for geeks
4_______1_______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_______71_______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_______1_______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_______71_______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
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
01

A Computer Science portal for geeks
4_______1_______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
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
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_______1_______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_______1_______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_______18_______0

 

A Computer Science portal for geeks
31

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

A Computer Science portal for geeks
4_______71_______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_______1_______5_______1_______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_______71_______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_______1_______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_______18_______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_______8_______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
A Computer Science portal for geeks
56
A Computer Science portal for geeks
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
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
84

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

A Computer Science portal for geeks
4_______1_______90

 

A Computer Science portal for geeks
91

A Computer Science portal for geeks
92_______8_______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_______8_______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_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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
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
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_______1_______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_______1_______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_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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
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
05

A Computer Science portal for geeks
4_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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_______1_______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_______18_______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
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_______1_______5
skeegrofskeeg
06
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4_______18_______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
Initial String: 
GeeksForGeeks

First character of String is: 
G

Last cha racter of String is: 
s
95_______18_______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_______1_______5
skeegrofskeeg
25
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4_______18_______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
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
4_______18_______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
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
A Computer Science portal for geeks
5
skeegrofskeeg
58
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
4_______18_______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
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
A Computer Science portal for geeks
5
skeegrofskeeg
73
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
4_______18_______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
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
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_______1_______5
skeegrofskeeg
94
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4_______18_______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(. ).   

Sự khác biệt giữa ký tự và chuỗi là gì?

Trước khi chúng ta xem xét chương trình java char to String, chúng ta hãy tìm hiểu sự khác biệt cơ bản giữa chúng. char là kiểu dữ liệu nguyên thủy trong khi String là một lớp trong java . char đại diện cho một ký tự trong khi Chuỗi có thể có 0 hoặc nhiều ký tự. Vì vậy, Chuỗi là một mảng ký tự.

Sự khác biệt giữa chuỗi và chuỗi trong Python là gì?

Sự khác biệt giữa trích dẫn chuỗi " và ' là chỉ ở phong cách - ngoại trừ việc cái này loại bỏ nhu cầu thoát cái kia bên trong nội dung chuỗi.

Chuỗi có phải là ký tự không?

Chuỗi ký tự là một chuỗi ký tự được biểu thị bằng các đoạn mã và được tổ chức thành một biến duy nhất . Các ký tự chứa biến chuỗi này có thể được đặt thành một độ dài cụ thể hoặc được chương trình phân tích để xác định độ dài của nó.

Sự khác biệt giữa %s và C là gì?

"%s" mong đợi một con trỏ tới một chuỗi kết thúc null ( char* ). "%c" cần một ký tự ( int ) .