Python learning notes 1 Basic Knowledge

Source: Internet
Author: User

Lovely Python sorting
Python-weak data type, no mandatory declaration required
Python-everything is an object
Pyhton-statement block ends with: And the next sentence is indented.
Python-reuse level code lines → functions → classes → modules
Python-functions supported
Python-KISS Principle = Keep it simple, stupid
I. Chinese support
#-*-Coding: UTF-8 -*-

Ii. Use modules
Import OS, sys, cmd
Fromt sp_tools. py import *
From threading import thread # Multithreading
Iii. Modules
OS. listdir ('path ');
OS. Walk ('path ')
File Operations
Open ('filename', 'A/W'). Write ('content ');
Iv. Functions
Def method (param1, param2 ):
Dosomething
V. Command Line Interaction
Import sys
SYS. Arg [x]
Vi. Category
Class classname (CMD. cmd ):
Def _ init _ (Self ):
Cmd. cmd. _ init _ (Self)
If _ name _ = '_ main __':
Dosomething
Thread
Class grepit (thread ):
Def _ init _ (self, param1, param2 ):
Thread. _ init _ (Self)
VII. Syntax
Filelist = OS. listdir ('path ')
For CDC in filelist:
If ". CDC" in CDC:
If keword in line:
Print line
Exception capture
Try:
For type in tryuni:
Try:
Ustring = Unicode ("% s}" % Type + stream, type)
# Try decode by list
Except t:
Continue
# Break! Continue try Decode guess
Except t:
Return U "Bad Unicode encode! "
8. Other Tools
Chardet encoding Detection
Epydoc py document Builder
Configparser file operation API
Web Framework
Karrigell webframeworks
Web. py
9. Others
Desktop development tk/tcl qt wxpython win32com

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.