TAILIEUCHUNG - Dive Into Python-Chapter 3. Native Datatypes

Tham khảo tài liệu 'dive into python-chapter 3. native datatypes', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 3. Native Datatypes You ll get back to your first Python program in just a minute. But first a short digression is in order because you need to know about dictionaries tuples and lists oh my . If you re a Perl hacker you can probably skim the bits about dictionaries and lists but you should still pay attention to tuples. . Introducing Dictionaries One of Python s built-in datatypes is the dictionary which defines one-to-one relationships between keys and values. A dictionary in Python is like a hash in Perl. In Perl variables that store hashes always start with a character. In Python variables can be named anything and Python keeps track of the datatype internally. A dictionary in Python is like an instance of the Hashtable class in Java. A dictionary in Python is like an instance of the Scripting. Dictionary object in Visual Basic. . Defining Dictionaries Example . Defining a Dictionary d server mpilgrim database master O d server mpilgrim database master d server 0 mpilgrim d database master d mpilgrim O Traceback innermost last File interactive input line 1 in KeyError mpilgrim 0 First you create a new dictionary with two elements and assign it to the variable d. Each element is a key-value pair and the whole set of elements is enclosed in curly braces. server is a key and its associated value referenced by d server is mpilgrim . database is a key and its associated value referenced by d database is master . 0 You can get values by key but you can t get keys by value. So d server is mpilgrim but d mpilgrim raises an exception because mpilgrim is not a key. . Modifying Dictionaries Example . Modifying a Dictionary d server mpilgrim database master d database pubs O

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.