The next day summary of cognitive apprenticeships

Today is the second day of hands-on training, teachers plan two days of the foundation python finish. Today's lesson has three parts, namely, common data types and built-in method, and document processing functions, is based on the knowledge in learning the basics yesterday, and further in-depth, I learned some difficulty, there are many who do not understand the need It was reviewed and re-study after class.

First, data types, data types include a list type, he is defined in [the], can store a plurality of values ​​of any type, separated by commas. We need to have access by index value (forward + reverse access access), sliced, length, members of the operation, addition, deletion and circulating a series of operations in the next study today, which are essential , and experienced a lot of distortion, it needs to be applied in different places, and that must be mastered off point for applications. Tuple type, he defined in () may be any type storing a plurality of values, separated by commas. Note, however, tuples and lists is not the same, only when defining initialization value can not be modified. The advantage is take up less memory space. Further comprising a dictionary, he is defined in the {}, a plurality of values ​​can be stored, key-value to access, fast speed value. Pay attention to key must be immutable type, value can be any type.

Then we learn the flow judge, in the usual course of study prior to have come across a similar concept, and therefore better able to deepen perception. determining if the syntax contains three, namely, if, elif, else, corresponding to different situations. while a loop, break out of this layer is a loop, continue this cycle is ended, to enter the next cycle.

Here is the file handle, here with a young teacher familiar Cai Xu Kun stems do demonstration, really memorable! The first is the open (), including sub-command wt: write text, rt: reading text, at: append text and so on. Also note that during the execution of python files! Also with open can manage open files, and the file will be automatically shut down after with finished.

The last is a function, the function had heard python is a major difficulty, to learn many of his small function, then what is it function, the function is just a tool. Use function to solve the problem of redundant code, make the code more clear structure and easy to manage. Use function must comply with the definition of first, and then call. It is noted here defines the syntax of the function, must be defined defind 'function name', and then add "parameter 1, parameter 2, etc. ', then pulls the line code the logic, and finally return to return.

Guess you like

Origin www.cnblogs.com/weigaiqinyi/p/11084993.html