1. List list=[' Jack ',' Bob ',' Harry ',' micle ', with brackets in the list, the elements in the list can be modified 2. Tuple touple = (10,34,56,22), tuples are represented by parentheses (), elements in tuples are not mutableOutput of the result:3. Dictionary dictionary={1: "Jack", 2: "Harry", 3: "Jimmy"}, acces
When building the SAE Python environment locally, the following error is always reported:1F:\workspace\dev\python\frikyskice\1>dev_server.py2 Traceback (most recent):3File"C:\Python27\Scripts\dev_server.py", line 205,inch4 Main (options)5File"C:\Python27\Scripts\dev_server.py", line 165,inchMain6Options.__dict__. Update (CONF)7Valueerror:dictionary Update Sequence Element#0 have length 1;
Level 3 menu, can go to the next level, can retreat to the previous levelDate = {"1": {"one": {"111": ["A", "B"], "("): ["C", "D"],}, "12": { "121": ["E", "F"], "122": ["G", "H"]}}, "2": {}, "3": {}}exit_flag = Falsewhile No T exit_flag:for i in Date:print (i) Choice = input ("SELECT INTO 1>>:") If choice in Date:while not Exit_flag:for i2 in Date[choice]: print ("\ T", i2) Choice2 = input ("SELECT INTO
Follow the development of Python in old boy education [Article 7]: Object-oriented 2, old boy python
Field
Static Field application:
Memory saving:
Generally, you can access your own fields.
Rule: common fields can only be accessed by objects, and static fields can be accessed by classes (object access is allowed
A detailed introduction to the dictionary in python and a detailed introduction to the python dictionary
1. What is a dictionary?
A dictionary is the only ing type in Python.
In a ing o
, Matplotlib, scipy respectively. Just click on the line to run. It is automatically retrieved to the Python installation path, as shown in the installation process diagram:Do not want to wordy, crazy point "next" becomes. About matplotlib,scipy in the same vein.But installation matplotlib is very annoying, will prompt missing "dateutil" and "pyparsing", so still have to install, but this don't worry, direct command under "Easy_install datautil", "Eas
Python from the start to the actual combat series--the definition of a directory dictionary
A dictionary is another variable container model, and can store any type of object, with key-value (Key-value) storage, with extremely fast lookup speed;Each key value of the dictionary (key=>value) pairs with a colon (
Python learning-Python container (list, tuples, Dictionary, set), python dictionary
List: The list is ideal for locating an element by order and position, especially when the order or content of the element changes frequently. Unlike strings, the list is variable.You can di
Dictionary and set in Python, Python dictionary set
I. Dictionary (dict)
1. Overview
The dictionary is the only ing type in Python.
You can only use immutable objects (such as strings)
tuple, so the list is not, the following example:1#!/usr/bin/python2 3Dict = {['Name']:'Zara',' Age':7};4 5Print"dict[' Name ']:", dict['Name'];6 #以上实例输出结果:7 #Traceback (most recent):8# File"test.py", line3,inch9# dict = {['Name']:'Zara',' Age':7};Ten#TypeError: List objects is unhashableSix, dictionary built-in funct
types, but the key is unique and unique. The value can be unique.
>>> D = {'A': 1, 'B': 2 }>>> d {'B': 2, 'A ': 1 }>>> L = [('jonh', 18), ('nancy ', 19)] >>> d = dict (L) # create from the list containing key values >>> d {'jonh': 18, 'nancy ': 19 }>>> T = tuple (L) >>> T ('jonh', 18), ('nancy ', 19)> d = dict (T) # create a key value using a tuple >>> d {'jonh': 18, 'nancy ': 19 }>>> d = dict (x = 1, y =
; # MS Excel can‘t open the document>>>>>> # or>>>>>> wb = load_workbook(‘document.xltm‘, keep_vba=True)>>> # If us need template document, then we need specify extension as *.xltm.>>> # If us need document, then we need specify attribute as_template=False.>>> wb.save(‘new_document.xlsm‘, as_template=True)>>> # MS Excel can‘t open the document
Import from File
The same way you write files, you can introduce Openpyxl.load_workbook () to open a workbook that already exists>>> from openpy
One: Object-oriented Programming1 Object-oriented programming--object oriented programming, short for OOP, is a programming idea. OOP takes objects as the basic unit of a program, and an object contains functions for data and manipulating data.2 object-oriented versus process-oriented differences:A process-oriented programming treats a computer program as a set of commands, that is, the sequential execution of a set of functions. In order to simplify
dictionary, it will be an error, so if you do not want an error, you can use the Get and SetDefault methods.>>> a{' A ': 1, ' B ': 2, ' C ': Ten, ' d ': 11}>>> a.setdefault (' C ', None) 10>>> a.setdefault (' W ', 1000) 1000>>> a{' A ': 1, ' B ': 2, ' C ': Ten, ' d ': One, ' W ': 1000}>>> a.get (' e ', ') 20>>> a{' A ': 1, ' B ':
dictionaries (dictionary)
>>> Help (Dict) on class dict in module __builtin__: dict (object) | dict (), New empty dictionary.| dict (map ping), new dictionary initialized from a mapping object ' s| (key, value) pairs.| Dict (seq), new dictionary initialized as if via:| d = {}| For K, V in seq:| d[k] = v| d
Python data types-tuples, commonly used dictionary operations, python data type dictionaryTuples
The Python tuples are similar to the list. The difference is thatThe elements of the tuples cannot be modified..
The tuples use parentheses, And the list uses square brackets.
Creating tuples is simple. You only need to add
DescribeThe Python Dictionary (Dictionary) Clear () function is used to delete all elements in the dictionary.GrammarClear () method syntax:Dict.clear () Parameters
NA.
return valueThe function does not have any return value.InstanceThe following example shows how the clear () function is used:#!/usr/bin/pythondict = {' Name ': ' Zara ', ' Age ':
appear two times. When created, if the same key is assigned two times, the latter value is remembered, as in the following example:
Copy Code code as follows:
#!/usr/bin/python
Dict = {' name ': ' Zara ', ' age ': 7, ' name ': ' Manni '};
print "dict[' name ']:", dict[' name ';
#以上实例输出结果:
#dict [' Name ']: Manni
2 The key must b
1.Python dictionary (Dictionary)A dictionary is another mutable container model and can store any type of object.each key value of the dictionary (key=>value) pair with a colon (:) split, Each pair is separated by a comma (,) , and the entire
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.