Python Learning Notes

Source: Internet
Author: User
Tags set set sublime text

the original from my Youdao notes-Li Wenzhong Hair Series first, language features1. An explanatory scripting language, non-compiled line 2. Data types: Integer, long, string, float, complex 3. Data structures: Ganso, lists, dictionaries (including two structures)--character channeling can be treated as a list operation 4. Variables are not declared, dynamically formulated when assigned (delay binding mechanism) 5. Objects everywhere (like JavaScript, functions can also be defined inside functions) 6. Writing Features
A. Must be indented
B. The code snippet is controlled directly by the indentation, and the colon is delimited by the block of code, such as class, function declaration
Class A:
xxxx
def b ()
xxxxx
7. Help function: Help,dir ... runoob tutorial python tutorials are mainly language features; see the Python Module chaptersingle quotes, double quotes, and multi-quote distinctions are essentially identity reference types, and are only incrementally extended on the derivative uses of compatible formats 1. The function can have multiple return values of 2. Object-oriented features: A. Classes class inherits Class B (a) (B inherits Class A) constructor _ _init_ _ (self) B. function declaration def funname (); function parameters can be set by default function classification: constructor, normal function, private function (starting with double underscore), proprietary function (double underscore beginning, double underscore end) 3. Support Lambada expressions such as: A=lambad X,y:x+yprint A (3) Data container 1. List-operation is flexible, can be embedded, can be stored in other types such as tuple2. Meta-progenitor tuple-mainly used for queries-efficiency list high, cannot be modified, can be changed by conversion to list and then turn back. can be nested tuple, can be embedded list, different from the array, there is no type, so you can mix the value and string 3. Dictionary Dict4. Set set-feature automatic weight second, the Python portalPython does not have a main function in execution Python, and if you run a. Py script, he is executed from the top down order. But Python provides a mechanism for implementing the main function. The following reference
#这里顺便定义一个函数def SayHello (): str= "D hi,there defined a function, you called it; __name__ is%s" Print (str%__name__); #这里模拟一个main函数, the main use of Python with variable __name__ to implement, when directly executed __name__ value is __main__, is called when the direct display as the class (file) name if __name__ = = "__main__": Print (' If the direct execution would be called; __name__ is%s '% (__name__)) SayHello ()
Python set working directory, get working directory (how Python code is organized)
>>> Import os>>> os.chdir (' D:\\python ') #设置工作目录 >>> os.getcwd () #获取工作目录 >>> Import Os>>> os.chdir (' D:\\python ') #设置工作目录 >>> os.getcwd () #获取工作目录 >>> import h #导入类 >>> H.sayhello () #执行导入的函数
>>>import SYS #获取python安装目录
>>>print Sys.prefix
Opening python--Understand how Python files are organized, understand the creation of source files (Good article, original collection here) iii.references to Python external packages  1. Direct installation 2. Install the python--easy_install installation and use the Easy_install installation by using Python. Note 3rd has relevant instructions iv. python debuggingOverall reference here selected part of the study 1.ipython installation reference here I start from the third step (do not rely on the IDE's debugging tools, through the IPDB command to control the rhythm of debugging)install, and verify the success, while the Python installation directory more related programs, as follows
IPDB common commands need to go into the debugging interface and then perform a debug caseThe debugging process is as follows: Debug case two, function debuggingDebugging process: Through two examples of practice basic grasp the Ipython +pdb debugging process; But not using the IDE mentioned in the articlepycharmt to practice. Note: The PDB mentioned above is a concept with the PDB file generated during C # debugging, which contains debugging information when the program compiles. Just vs this powerful IDE lets us ignore the nature of the PDB file. This design feature is interlinked in many languages. Five, Sublime text under the Pyhon debugging environment  

Use sublime text to build a Python debugging environment , the title contains reference links, after the previous practice here the content becomes simple (essentially also through the sublimerepl plugin control p db file Debug). It is possible that the relevant components have been installed before, and now you can go to the third step to debug directly.

For example, we want to debug fun.py, as follows: Note that the above breakpoint can not be added to the Code pdb.set_trace (), you can enter the PDB directly with the instruction "B 6" can be created on the sixth line breakpoint. Vi. Follow-up studyPython frame here flask (JINJA2/WERKZEUG)

Python Learning notes

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.