Làm cách nào để gán một chuỗi cho một chuỗi trong python?

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

________ 73 ________ 74 ________ 75

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

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

A Computer Science portal for geeks
84

________ 73 ________ 74 ________ 187

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
70
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
76

________ 73 ________ 74 ________ 279

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
72
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
77

A Computer Science portal for geeks
78

________ 73 ________ 74 ________ 481

_______482____483

A Computer Science portal for geeks
82
A Computer Science portal for geeks
85

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
88
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
81

đầ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




A Computer Science portal for geeks
02

A Computer Science portal for geeks
03

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

________ 73 ________ 74 ________ 607

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
80
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
85

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
88
A Computer Science portal for geeks
7

A Computer Science portal for geeks
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
91____792
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
93

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
95

A Computer Science portal for geeks
4
A Computer Science portal for geeks
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
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
91____002
A Computer Science portal for geeks
03
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
93

đầu ra.  

A Computer Science portal for geeks
8

Đả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




A Computer Science portal for geeks
05

________ 006 ________ 74 ________ 008

A Computer Science portal for geeks
4
A Computer Science portal for geeks
10
A Computer Science portal for geeks
02
A Computer Science portal for geeks
03
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
93

đầu ra

A Computer Science portal for geeks
7

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
14

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

________ 006 ________ 74 ________ 008

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

A Computer Science portal for geeks
20

A Computer Science portal for geeks
06
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
23
A Computer Science portal for geeks
24
A Computer Science portal for geeks
25

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

A Computer Science portal for geeks
4
A Computer Science portal for geeks
28

đầu ra

A Computer Science portal for geeks
7

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
29

A Computer Science portal for geeks
30

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

________ 73 ________ 74 ________ 607

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
80
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
43

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
46
A Computer Science portal for geeks
7

A Computer Science portal for geeks
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
91____050______051
A Computer Science portal for geeks
52
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
93

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

A Computer Science portal for geeks
55

A Computer Science portal for geeks
56

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
59
A Computer Science portal for geeks
60

________ 061 ________ 062 ________ 07

A Computer Science portal for geeks
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
91____050
A Computer Science portal for geeks
51
A Computer Science portal for geeks
02
A Computer Science portal for geeks
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
93

đầu ra.  

A Computer Science portal for geeks
8

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
71

A Computer Science portal for geeks
72

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

________ 73 ________ 74 ________ 076

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
80
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
84

A Computer Science portal for geeks
85

A Computer Science portal for geeks
86

A Computer Science portal for geeks
87

A Computer Science portal for geeks
88
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
90____181

A Computer Science portal for geeks
92______069______094
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
96

________ 097 ________ 74 ________ 099

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

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

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
07

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
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
10_______792
A Computer Science portal for geeks
51
A Computer Science portal for geeks
69
A Computer Science portal for geeks
94
A Computer Science portal for geeks
60
A Computer Science portal for geeks
96
A Computer Science portal for geeks
60
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
10
A Computer Science portal for geeks
50
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
20

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

Lỗi.  

Traceback [cuộc gọi gần đây nhất gần đây nhất].
Tệp “/home/360bb1830c83a918fc78aa8979195653. py”, dòng 10, trong 
String1[2] = ‘p’ 
TypeError. đố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
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
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
0

________ 73 ________ 74 ________ 076

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
80
A Computer Science portal for geeks
7

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

________ 73 ________ 74 ________ 739

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

A Computer Science portal for geeks
4
A Computer Science portal for geeks
81

đầu ra.  

A Computer Science portal for geeks
0

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
46

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
47

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

________ 73 ________ 74 ________ 076

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
80
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
97
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
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
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
92
A Computer Science portal for geeks
51
A Computer Science portal for geeks
69
A Computer Science portal for geeks
94
A Computer Science portal for geeks
60
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
10
A Computer Science portal for geeks
50
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
20

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

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

Lỗi.  

Chuỗi ban đầu.
Xin chào, tôi là người lập dị

Xóa ký tự ở Chỉ mục thứ 2.
Trợ giúp, tôi là một người lập dị

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
46

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

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

________ 73 ________ 74 ________ 076

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
80
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
4
A Computer Science portal for geeks
81

Lỗi.  

Traceback [cuộc gọi gần đây nhất gần đây nhất].
Tệp “/home/e4b8f2170f140da99d2fe57d9d8c6a94. py”, dòng 12, trong 
print[String1] 
NameError. 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 SyntaxError 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

A Computer Science portal for geeks
802

A Computer Science portal for geeks
803

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

A Computer Science portal for geeks
805

________ 73 ________ 74 ________ 1808

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
811
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
816

________ 73 ________ 74 ________ 1819

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
822
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
827

________ 73 ________ 74 ________ 1830

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
833
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
838

A Computer Science portal for geeks
839

________ 73 ________ 74 ________ 1842

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
845
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
838

A Computer Science portal for geeks
851

________ 73 ________ 74 ________ 1854

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
857
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
838

A Computer Science portal for geeks
863

________ 73 ________ 74 ________ 1866

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
869
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
81

đầu ra

A Computer Science portal for geeks
8

Để 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




A Computer Science portal for geeks
873

________ 73 ________ 74 ________ 1876

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
879
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
884

A Computer Science portal for geeks
885

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
888
A Computer Science portal for geeks
889

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
892
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
897

________ 73 ________ 74 ________ 2700

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
703
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
884

A Computer Science portal for geeks
885

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______74
A Computer Science portal for geeks
888
A Computer Science portal for geeks
700

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
716
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
81

đầ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
9

Đị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

A Computer Science portal for geeks
721

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

A Computer Science portal for geeks
723

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
726
A Computer Science portal for geeks
727
A Computer Science portal for geeks
728
A Computer Science portal for geeks
5
A Computer Science portal for geeks
730
A Computer Science portal for geeks
731
A Computer Science portal for geeks
732
A Computer Science portal for geeks
731
A Computer Science portal for geeks
734
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
738
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
743

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
746
A Computer Science portal for geeks
727
A Computer Science portal for geeks
728
A Computer Science portal for geeks
5
A Computer Science portal for geeks
730
A Computer Science portal for geeks
731
A Computer Science portal for geeks
732
A Computer Science portal for geeks
731
A Computer Science portal for geeks
734
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
758
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
763

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
766
A Computer Science portal for geeks
727
A Computer Science portal for geeks
728
A Computer Science portal for geeks
769
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
730
A Computer Science portal for geeks
772
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
732
A Computer Science portal for geeks
775
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
734
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
781
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
81

đầ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




A Computer Science portal for geeks
785

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
788
A Computer Science portal for geeks
727
A Computer Science portal for geeks
728
A Computer Science portal for geeks
5
A Computer Science portal for geeks
792
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
796
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
701

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
704
A Computer Science portal for geeks
727
A Computer Science portal for geeks
728
A Computer Science portal for geeks
5
A Computer Science portal for geeks
708
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
712
A Computer Science portal for geeks
7

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

A Computer Science portal for geeks
717

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
720
A Computer Science portal for geeks
727
A Computer Science portal for geeks
728
A Computer Science portal for geeks
5
A Computer Science portal for geeks
03
A Computer Science portal for geeks
725
A Computer Science portal for geeks
726
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
5
A Computer Science portal for geeks
730
A Computer Science portal for geeks
7

A Computer Science portal for geeks
4
A Computer Science portal for geeks
81

đầ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 [. ].   

Bạn có thể gán một chuỗi cho một chuỗi không?

Như chúng ta biết rằng Chuỗi là một đối tượng bất biến, vì vậy chúng ta chỉ có thể gán một chuỗi cho một chuỗi khác để sao chép nó . Nếu giá trị chuỗi ban đầu sẽ thay đổi, nó sẽ không thay đổi giá trị của Chuỗi mới vì tính bất biến.

Tôi có thể gán chuỗi trong Python không?

Chà, về cơ bản, bạn không thể . Chuỗi là bất biến. 00. 08 Nhiều loại dữ liệu mà bạn có thể thấy cho đến nay là không thay đổi.

Chúng ta có thể gán lại giá trị cho chuỗi trong Python không?

Có, các biến trong Python có thể được gán lại cho một giá trị mới có kiểu dữ liệu khác với giá trị hiện tại . Trên thực tế, các biến có thể được gán lại cho bất kỳ giá trị hợp lệ nào trong Python, bất kể giá trị hiện tại của nó là bao nhiêu.

Bạn có thể gán lại một chuỗi không?

Các đối tượng chuỗi được thiết kế để không thay đổi. Không có cách nào để thay đổi hoặc thao tác dữ liệu của họ sau khi đối tượng được tạo. Mặc dù bạn không thể thay đổi String , nhưng bạn có thể chỉ định lại các tham chiếu của nó .

Chủ Đề