W3Schools được tối ưu hóa cho việc học và đào tạo. Ví dụ có thể được đơn giản hóa để cải thiện việc đọc và học tập. Hướng dẫn, tài liệu tham khảo và ví dụ được xem xét liên tục để tránh lỗi, nhưng chúng tôi không thể đảm bảo tính chính xác đầy đủ của tất cả các nội dung. Trong khi sử dụng W3Schools, bạn đồng ý đã đọc và chấp nhận các điều khoản sử dụng, cookie và chính sách bảo mật của chúng tôi.
Bản quyền 1999-2022 bởi dữ liệu refsnes. Đã đăng ký Bản quyền. W3Schools được cung cấp bởi W3.CSS.
W3Schools is Powered by W3.CSS.
Những gì được đặt theo nghĩa đen
SETIS Bộ sưu tập của bộ dữ liệu chưa được đặt hàng. Nó được bao quanh bởi {} và mỗi phần tử được phân tách bằng dấu phẩy [,].
Ví dụ: Chúng ta có thể tạo một tập hợp các nguyên âm và trái cây. & NBSP;
Các
>>> a = 'A string' # string literal with single quotes >>> b = "A string" # string literal with double quotes >>> b == a # there is no difference between these strings True
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash81
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash36
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash84___
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem
Đặc biệt theo nghĩa đen là gì
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash
Python chứa một nghĩa đen đặc biệt [không có]. Không có ai được sử dụng để xác định một biến null. Nếu không có ai được so sánh với bất cứ điều gì khác ngoài ‘không có, thì nó sẽ trả về sai.
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash94
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash96
>>> print['Backslash before "n", as in \n, inserts a new line character'] #doctest: +NORMALIZE_WHITESPACE Backslash before "n", as in , inserts a new line character
Nếu bạn không muốn dấu gạch chéo ngược có ý nghĩa đặc biệt này, hãy đặt tiền tố theo nghĩa đen của bạn với ‘R, có nghĩa là Raw Raw:
>>> print[r'Prefixed by "r" the \n no longer inserts a new line'] Prefixed by "r" the \n no longer inserts a new line
Bạn có thể sử dụng trích dẫn ba để kèm theo các chuỗi có nhiều hơn một dòng:
>>> print['''This string literal ... has more than one ... line'''] This string literal has more than one line
Báo giá ba có thể sử dụng dấu ngoặc kép đơn hoặc kép:
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line
Nói chung, nghĩa đen là một ký hiệu để thể hiện một giá trị cố định trong mã nguồn. Chúng cũng có thể được định nghĩa là giá trị thô hoặc dữ liệu được đưa ra trong các biến hoặc hằng số. Python có các loại nghĩa đen khác nhau như:
- Chuỗi chữ
- Chữ số
- Boolean Biết chữ
- Bộ sưu tập theo nghĩa đen
- Văn học đặc biệt
Chuỗi chữ là gì
Một chuỗi theo nghĩa đen có thể được tạo bằng cách viết một văn bản [một nhóm các ký tự] được bao quanh bởi một câu nói đơn [], gấp đôi [phạm vi] hoặc ba trích dẫn. & nbsp; bằng cách sử dụng trích dẫn ba, chúng tôi có thể viết các chuỗi nhiều dòng hoặc hiển thị chúng theo cách mong muốn. & NBSP;
Ví dụ: Ở đây Geekforgeeks là một chuỗi theo nghĩa đen được gán cho một biến [s]. & Nbsp;Here geekforgeeks is a string literal that is assigned to a variable[s].
Python3
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash0
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash2
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash3
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash5
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash6
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash9
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash3
Đầu ra
geekforgeeks geekforgeeks geek for geeks
Nhân vật theo nghĩa đen là gì
Nó cũng là một loại chuỗi theo nghĩa đen trong đó một ký tự duy nhất được bao quanh bởi các trích dẫn đơn hoặc đôi.
Example:
Python3
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash4
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash6
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash7
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash9
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Backslash before "n", as in \n, inserts a new line character'] #doctest: +NORMALIZE_WHITESPACE Backslash before "n", as in , inserts a new line character1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Backslash before "n", as in \n, inserts a new line character'] #doctest: +NORMALIZE_WHITESPACE Backslash before "n", as in , inserts a new line character3
Đầu ra
n a
Nhân vật theo nghĩa đen là gì
Nó cũng là một loại chuỗi theo nghĩa đen trong đó một ký tự duy nhất được bao quanh bởi các trích dẫn đơn hoặc đôi.
- Integer
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash
4>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash
1>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash
6- Complex.
Integer:
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash7
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash9
Example:
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Backslash before "n", as in \n, inserts a new line character'] #doctest: +NORMALIZE_WHITESPACE Backslash before "n", as in , inserts a new line character1a‘ is a binary literal, ‘b’ is a decimal literal, ‘c‘ is an octal literal, and ‘d‘ is a hexadecimal literal. But on using the print function to display a value or to get the output they were converted into decimal.
Python3
Số là nghĩa đen là gì
Chúng là bất biến và có ba loại chữ số: & nbsp;
Float Python
Cả số dương và số âm bao gồm 0. Không nên có bất kỳ phần phân số nào.
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print[r'Prefixed by "r" the \n no longer inserts a new line'] Prefixed by "r" the \n no longer inserts a new line7
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem0
Nhân vật theo nghĩa đen là gì
Nó cũng là một loại chuỗi theo nghĩa đen trong đó một ký tự duy nhất được bao quanh bởi các trích dẫn đơn hoặc đôi.
Example:
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash4
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash6
Python3
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash7
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash9
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Backslash before "n", as in \n, inserts a new line character'] #doctest: +NORMALIZE_WHITESPACE Backslash before "n", as in , inserts a new line character1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['''This string literal ... has more than one ... line'''] This string literal has more than one line5
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem1
Complex
Nhân vật theo nghĩa đen là gìa + bj, where ‘a‘ is the real part and ‘b‘ is the complex part.
Example:
Python3
Nó cũng là một loại chuỗi theo nghĩa đen trong đó một ký tự duy nhất được bao quanh bởi các trích dẫn đơn hoặc đôi.
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash4
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash6
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line5
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem2
Nhân vật theo nghĩa đen là gì
Nó cũng là một loại chuỗi theo nghĩa đen trong đó một ký tự duy nhất được bao quanh bởi các trích dẫn đơn hoặc đôi.true and false. In Python, True represents the value as 1 and False represents the value as 0.
>>> print["Double quoted string with ' is no problem"]
Double quoted string with ' is no problem
>>> print["Double quoted string containing \" is OK with backslash"]
Double quoted string containing " is OK with backslash
4>>> print['Single quoted string containing \' is OK with backslash']
Single quoted string containing ' is OK with backslash
1 >>> print["Double quoted string with ' is no problem"]
Double quoted string with ' is no problem
>>> print["Double quoted string containing \" is OK with backslash"]
Double quoted string containing " is OK with backslash
6
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash7
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash9a‘ is True and ‘b‘ is False because 1 is equal to True.
Python3
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Backslash before "n", as in \n, inserts a new line character'] #doctest: +NORMALIZE_WHITESPACE Backslash before "n", as in , inserts a new line character1
Số là nghĩa đen là gì
Chúng là bất biến và có ba loại chữ số: & nbsp;
Float Python
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem04
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem05
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem08
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem09
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem12
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem13
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem16
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem17
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem3
Nhân vật theo nghĩa đen là gì
Nó cũng là một loại chuỗi theo nghĩa đen trong đó một ký tự duy nhất được bao quanh bởi các trích dẫn đơn hoặc đôi.
Python3
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash4
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash6
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash7
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash9
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Backslash before "n", as in \n, inserts a new line character'] #doctest: +NORMALIZE_WHITESPACE Backslash before "n", as in , inserts a new line character1
Số là nghĩa đen là gì
Chúng là bất biến và có ba loại chữ số: & nbsp;
Float Python
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem62
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem63
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem66
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem67
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem70
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem71
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem74
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem05
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem78
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem09
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem4
Nhân vật theo nghĩa đen là gì
Nó cũng là một loại chuỗi theo nghĩa đen trong đó một ký tự duy nhất được bao quanh bởi các trích dẫn đơn hoặc đôi.
>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash
4>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash
1>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash
6>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash
7>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash
1>>> print["Double quoted string with ' is no problem"] Double quoted string with ' is no problem >>> print["Double quoted string containing \" is OK with backslash"] Double quoted string containing " is OK with backslash
9>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash
8>>> print['Backslash before "n", as in \n, inserts a new line character'] #doctest: +NORMALIZE_WHITESPACE Backslash before "n", as in , inserts a new line character
1- Số là nghĩa đen là gì
Chúng là bất biến và có ba loại chữ số: & nbsp;
Float Pythoncontains items of different data types. The values stored in List are separated by a comma [,] and enclosed within square brackets[[]]. We can store different types of data in a List. Lists are mutable.
Example:
Python3
Cả số dương và số âm bao gồm 0. Không nên có bất kỳ phần phân số nào.
Chúng tôi đã chỉ định các chữ số nguyên [0B10100, 50, 0O320, 0x12B] cho các biến khác nhau. Ở đây, ‘A‘ là một nghĩa đen nhị phân, ‘B, là một hình chữ thập,‘ C ‘là một nghĩa đen, và‘ D là một nghĩa đen của hình lục giác. Nhưng khi sử dụng hàm in để hiển thị giá trị hoặc để có được đầu ra, chúng đã được chuyển đổi thành thập phân.
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash05
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash07
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem5
Nhân vật theo nghĩa đen là gìTuple literal
Nó cũng là một loại chuỗi theo nghĩa đen trong đó một ký tự duy nhất được bao quanh bởi các trích dẫn đơn hoặc đôi.[]‘ and each element is separated by the comma[,]. It is immutable.
Example:
Python3
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash08
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem29
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem84
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem89
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem84
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash15
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem84
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash17____83
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash19
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line8
>>> print["""This string literal ... also has more than one ... line"""] This string literal also has more than one line9
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem84
n a6
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem84
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem91__
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash31
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash33
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem6
Từ điển theo nghĩa đen là gìDictionary literal
Từ điển lưu trữ dữ liệu trong cặp giá trị khóa. Nó được bao quanh bởi niềng răng xoăn ‘{}‘ và mỗi cặp được phân tách bằng dấu phẩy [,]. & nbsp; chúng ta có thể lưu trữ các loại dữ liệu khác nhau trong từ điển. Từ điển là có thể thay đổi.{}‘ and each pair is separated by the commas[,]. We can store different types of data in a dictionary. Dictionaries are mutable.
Example:
Python3
Các
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash49
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash36__
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash65
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash67
Output:
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem7
Những gì được đặt theo nghĩa đenSet literal
SETIS Bộ sưu tập của bộ dữ liệu chưa được đặt hàng. Nó được bao quanh bởi {} và mỗi phần tử được phân tách bằng dấu phẩy [,].is the collection of the unordered data set. It is enclosed by the {} and each element is separated by the comma[,].
Ví dụ: Chúng ta có thể tạo một tập hợp các nguyên âm và trái cây. & NBSP; We can create a set of vowels and fruits.
Python3
Các
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash81
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash1
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash36
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash84___
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash91
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash93
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem8
Từ điển theo nghĩa đen là gì
Từ điển lưu trữ dữ liệu trong cặp giá trị khóa. Nó được bao quanh bởi niềng răng xoăn ‘{}‘ và mỗi cặp được phân tách bằng dấu phẩy [,]. & nbsp; chúng ta có thể lưu trữ các loại dữ liệu khác nhau trong từ điển. Từ điển là có thể thay đổi.‘None’ is used to define a null variable. If ‘None’ is compared with anything else other than a ‘None’, it will return false.
Example:
Python3
Các
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash8
>>> print['Single quoted string containing \' is OK with backslash'] Single quoted string containing ' is OK with backslash98
Đầu ra
>>> print['Single quoted string with " is no problem'] Single quoted string with " is no problem9