Python course day notes-la, python course-la
Http://www.cnblogs.com/onda/ ---------------------- 20170423 A: Cpython pypy difference; Cpython is a line of interpretation, pypy is the entire file interpretation II: pycharm use: 1: Create Project 2: Set Character Set utf8 3: set the default file creation start #! /Usr/bin/env python and utf8 reading 4: Modify the scroll wheel (Ctrl) to modify the text size --> Search mous 3 in Setting: input and Output: input print 4: variable: 1: letter, number (cannot begin), underline 2: cannot be a python default string 3: conforms to the common thinking, separated by underline 5: comment, single line # multiple lines ''' 6: Format (indent): pycharm is a TAB (4 spaces ). 7. if judgment: if condition: expression elif condition: expression else: expression 8: loop 1: while expression: (if expression is True, it enters the loop) expression continue jump out of this loop break jump out of the loop 2 for I (loop body) in range (10) is the loop body: expression 9: Data Type: 1 integer int 2 Pol bool 3 string str 10: Others: 1: Remove blank strip () lstrip () 2: split ('delimi') default is space 3: len 4: The index string and list are ordered. You can print "A" through A = 'AB' a [0]. 5: The slice is similar to the index, not only the specified position, you can also specify A segment A [0: 2] 11: list A = [] to convert the string to list using list. Reverse str #### list method. index ('value') locate the position of this value. append ('value') --> append the value. count ('value') --> count, the number of. extend ('LIST') --> merge list. index () --> View the position of. insert (location, 'value') --> insert. pop () --> Delete the last. remove () --> Delete the specified. reverse () --> flip list. sort () --> sort 12: dictionary B = {'key': value} value can be A dictionary, list, And tuples which cannot be changed to a = ('A ', 'B', 'C ') ### the method has only two index locations: count the number of units to be searched ########## conversion between tuples and lists tuple (list) convert the list to the list (tuples). Convert the tuples to the list 13: IO file. Open f1_file('1.txt ', 'R') F. read () F. close () Write: ww.file('1.txt ', 'w') w. write () W. close ()