04_ Project Combat
Initialization and exit of PygamePygame.init () Pygame.quit () exit ()
Pygame. Rect (X,y,width,height) class describing a rectangleContains the following properties (x, y, size, width, height, left, right, top, bottom,
Configparser module:is the module used by the Python standard library to parse the configuration file.Format:Section: Using [] to mark section names: or =: using: or = Assignment[Websv]ip: ' 192.168.1.10 ' port:443name = ' root ' pw = ' root1990 '
02_python Foundation _day06
Definition of a stringStrings are a string of characters, enclosed in a pair of single or double quotation marks.
string slicesSlicing is the use of index values to cut out small strings from a large string for
Tag: Precedence equals ESS requires logical statement result while loop%sA. While loopBasic usage:While condition: Code Block 1Else Code Block 2Running process: 1) When the condition is set, execute code block 12) again determine if the
Exercises:
Define a method Get_num (NUM), the num parameter is a list type, and the element in the list is a numeric type. The other type is an error, and returns an even list: (Note: The elements in the lists are even).def get_num(num):
Python dictionary# Data Type partitioning: mutable data type, immutable data type # immutable data type: ganso bool str int HASH # mutable data type: List Dict (dictionary) set (set) non-hash # Dict key (must be hash) value (Arbitrary data class #
Format ()Positional parameter {}>>> "{0} love {1}.com". Format ("I", "cat")' I Love cat.com 'Keyword parameters>>> ' {I} love {cat}.com '. Format (i= "You", cat= "Me")' You love me.com 'Combining positional and keyword parameters, the positional
1. Write an adorner to see when the function executesImport datetimeImport timedef jishi (fun): Def warper (): Start_time = Datetime.datetime.now () Fun () End_time = Datetime.datetime.now () Haoshi = (end_time-start_time).
The concept of constants in Python is actually the concept of an object (so-called in Python, where everything is object), and all assignment operations are references to operand objects. In Python, each variable has a unique ID, which can be called
class:A class of things with the same attributes and skills.object:the specific performance of the class.class keywordClass Name: (class name should be capitalized first)code block.country = ' China ' first part: Static variable, static fielddef
Test environment Python3, do not know Python2 can run.The code is as follows:#-*-Coding:utf-8-*-Import Turtle as TT.pensize (4) # Set the size of the brushT.colormode (255) # Set GBK color range to 0-255T.color ((255,155,192), "Pink") # Set brush
#单例的作用就是为了节约系统资源, every time you generate an object, you go back to taking up memory space, so the singleton can end the problem. #非单例模式, non-singleton mode in each instantiation will call memory, so the number of calls, it can cause memory waste
1. Use only within the interpreter itself.Condition: Code in test.lianx_2.py:Class A (object): def __init__ (self,name): self.name=name def c (self): print ' name:%s '%self.nameb=a (' RR ') B.C () Results: NAME:RR__import__
Configparser module for operating configuration filesA configuration file (INI file) consists of a section, a key, a value1. Config=configparser.configparser () Create Configparser instance2. Config.sections () returns the section sequence in the
# title = "Alice in Wonderland"# Print (Title.split ())def count_words (filename): "Count how many words in a text file" Try WithOpen (filename)As F_obj:Contents = F_obj.read () ExceptFilenotfounderror: Pass #msg = "Sorry, the file" + filename + "
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service