Here are some of the things you need to be particularly aware of when learning Python:1, the program appears in Chinese, the following error occurs when running: Syntaxerror:non-utf-8 code starting with ' \xc1 'is a coding error, plusOr#-*-Coding:
Common string formatting methods in Python include two types: string insertion (str%), Format function (Str.format ())1. String insertionString insertion is a simple way to format a string, which differs little from the C and Fortran languages.
JSON facilitates the interaction of data between different programming languagesJSON serializationJSON serialization of data#-*-Coding:utf-8-*-__author__ = "MuT6 sch01ar" Import jsoninfo = { ' name ': ' John ', ' age ': ', ' sex ': ' Male ',
Randomly forms a five-bit character code consisting of letters and numbers. [[email protected] python]# vim timee.pyimport randomdef coder (): code = ' for i in range (5): add = Rando M.choice ([Random.randrange (Ten), Chr (Random.randrange (65
The nature of function namesThe function name is essentially the memory address of the function.1. Can be assigned to other variables, referenceddef func (): Print ('infunc'= funcprint(f)2. Elements that can be used as container typesdefF1
If multiple functions want to implement different functions through an adorner, you can pass parameters to the adorner, allowing the function in the adorner to judge the parameters to achieve different functions.#-*-Coding:utf-8-*-__author__ = "MuT6
The tuple (typle) list has no subtraction and division, but it has addition and multiplication.1, addition, that is, the addition of elements. Only list and tuple can be added, not other types.t= (1,) + (2, 3, 4) print (T, type (t))Output to(1, 2, 3,
Pickle is a Python data interaction that serializes the data and reads it when neededSerialization of Pickle#-*-Coding:utf-8-*-__author__ = "MuT6 sch01ar" import pickledef Test (): print (' test ') info = { ' name ': ' John ', c2/> ' age ': $,
The configuration about Python1,Before the installation of a 2.7, unfortunately, immediately after the proposal to see the predecessors: Novice should learn 3 x, 3 and 2 is incompatible, everything to 3 development, so, decisively abandon 2, start
Adorners are defined by functions and used to decorate functions.The adorner does not change the source code and operation mode of the decorated functionHow do you achieve this effect?#-*-Coding:utf-8-*-__author__ = "MuT6 sch01ar" Import timedef
Dynamic parameters: One, *args:args is Ganso, it contains all the positional parameters.1, the first form parameter contains only *args.def func (*args): Print(*args,type (args)) func (1,2,3,4,5)only *args are included in formal parameters2,
Let Python automatically manipulate the desktop or application window, click, slide the mouse, enter text, etc.# coding=utf-8from Pymouse Import pymousefrom pykeyboard import pykeyboardimport time, Randomimport Pyautogui as PAGM = Py Mouse () K =
Python built-in module struct instance details, pythonstruct
This article focuses on the relevant content of the Python built-in module struct, as follows.
In Python, the types of variables are only list, ancestor, Dictionary, set, and other
5. Comments, branch structure, loop structure, pseudo "select structure", and branch
Note:
Python uses # As the line annotator and three quotation marks as the multi-line annotator
Branch Structure: if-else:
A = int (input ("your score is:")
Python built-in modules
# Continuous update
# Import a built-in module, for example, import abc, to import the abc module. Of course, the module can also be written by itself, which is equivalent to a class, this is because the environment is idle
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