programmer should understand these concepts quite well, So after you squeeze out the precious hour to read this short tutorial, you'll be able to familiarize yourself with Python as soon as possible with the knowledge of the migration analogy, and then start programming with it as soon as possible.Of course, the 1-hour learning of Python is quite grandstanding.
syssys.path.append (' D:\\download ') from parent.child.a import add_funcprint sys.pathprint "Import Add_func from Module A "print" Result of 1 plus 2 is: "Print Add_funcSummarizeYou will find this tutorial quite simple. Many of the python features are implicitly presented in the code, including: Python does not need to explicitly declare data types, keyword des
the exit string, the connection is closed directly.To test this server program, we also need to write a client program:Note that the client program runs out, and the server program will run forever, you must press CTRL + C to exit the program.SummarySocket programming with the TCP protocol is very simple in Python, for the client, to actively connect to the server's IP and the specified port, for the server, to first listen to the specified port, and
a third-party library for others.Many large web sites are developed in Python, such as YouTube, Instagram, and the domestic watercress. Many large companies, including Google, Yahoo, and even NASA, have used python in large numbers.Uncle Turtle to Python positioning is "elegant", "clear", "simple", so the Python progr
numbers to each other:9.Python later added support for Unicode, the string in Unicode represented by U ' ... '10. Convert u ' xxx ' to UTF-8 encoded ' xxx ' with encode (' Utf-8 ') method:1. In turn, convert the UTF-8 encoded string ' xxx ' to the Unicode string U ' xxx ' using the decode (' Utf-8 ') method:2. In Python, the format used is consistent with the C language and is implemented in%The 3.% operat
contains the yield keyword, then the function is no longer a normal function, but a generator:3. The most difficult thing to understand is that generator is not the same as the process of executing a function. The function is executed sequentially, the return statement is encountered, or the last line function statement is returned. The function that becomes generator, executes at each call to next (), encounters a yield statement return, and executes again from the yield statement that was las
','Vincent','Tingna']>>> Names.pop ()#most one element is deleted'Tingna'>>>names['Frank','Lock','Hardy','Vincent']>>> Names.pop (0)#kick out the first element'Frank'>>>names['Lock','Hardy','Vincent']>>> Names.reverse ()#reverse Order>>>names['Vincent','Hardy','Lock']>>> Names.sort ()#从小到达>>>names['Hardy','Lock','Vincent']>>> Names.sort (Key=len)#Sort by length>>>names['Lock','Hardy','Vincent']>>> Names.sort (reverse=true)#从大到小>>>names['Vincent','Lock','Hardy']Three. Tuples immutable sequencesWi
: ' This is String '
Double quotation marks: "This is a string"
Three quotation marks: "This is a string" or "" "This is a string" "
Escape
1>>>#\ ' escaped as '2>>>Print 'what\ ' s your name'3What's your name4>>>#\ nthe escape for line break5>>>Print 'First Line\nsecond line'6 First Line7 Second Line8>>>9>>>escaped
Natural string
If you want to indicate certain strings that do not require special handling such as escape characters, you need to specify a natural s
. Character Case conversion: Python provides a number of useful string case conversions, including all conversions, where the first letter of the word is converted to uppercase. >>>'Frank'. Upper ()#Convert to uppercase'FRANK'>>>'Frank'. Lower ()'Frank'>>>'FRANK'. Islower () False>>>'Frank'. Islower () True>>>'My name is Frank'. Title ()#capitalize the first letter of each word'My Name is Frank'>>>'Aaddee'. Swapcase ()#convert each letter case to a
has a "return value", the try also has a "return value", then call the method to get what data it. Let's take a look at the code below.Note: It is not clear why this design is returned to the finally.defDiv (val1,val2):Try: returnval1/Val2except(Zerodivisionerror,typeerror), E:returnEfinally: return 'I am finally'PrintDiv (1,'2')PrintDiv ()>>i amfinally>>i amfinallythree. Summary:This chapter records the creation and basic use of functions.And the use of exceptions. There is stil
functional programming refers to this highly abstract programming paradigm.The 1.map () function receives two parameters, one is a function, the other is a sequence, and the map functions the incoming function to each element of the sequence sequentially and returns the result as a new list.2.reduce functions a function in a sequence [X1, x2, x3 ...] , the function must receive two parameters, and reduce will continue to accumulate the result and the next element of the sequence,The 3.
I use Python to crawl the movie Heaven contains the source code is very clear, so that 0 basic Python novice can easily learn, really not too much.Let's look at some of our code and crawl to the results:Crawled Movie Resources: (You can get a video tutorial)Steps:1, first import the required modules2, access to web inf
Concise Python tutorial --- 16. What to learn next
So far, the basic knowledge about Python has been introduced. So what should I learn next?
Graphics Software
There are many options for using Python Gui:
Pyqt this is the
': ' Unkown '}3. Has_key () and key in DIC determine if a key is included4. Items and Iteritems: Gets a list of dictionary elements for the traversal of a dictionary, which is the keyvaluepair >>> workmsg = {'Frank':'Coder','Nancy':'HR','Vincent':'Project Manager'}>>>Workmsg.items () [('Frank','Coder'), ('Vincent','Project Manager'), ('Nancy','HR')]>>>list (Workmsg.iteritems ()) [('Frank','Coder'), ('Vincent','Project Manager'), ('Nancy','HR')]>>>5.keys and Iterkeys as well as values and ite
2.1 python3.6 Tool UseAfter running Python's own idle, enter the Python command, such as print (' Hello World ') and output Hello World after carriage returnThe Mac system will appear for a period of warning:the version of TCL/TK in use can ustable. Prompt is not stable, will appear unable to input Chinese, need to download and install update TCLTK.2.2 Pycharm Tools for useFor the first time use, tick the default configuration environment, create a ne
#-*-coding:utf-8-*-2 3 4 classshortinputexception (Exception):5 """A user-defined Exception class."""6 7 def __init__(self, length, atleast):8Exception.__init__(self)9Self.length =lengthTenSelf.atleast =atleast One A - Try: -s = raw_input ("Enter something --") the ifLen (s) : - Raise Shortinputexception (Len (s), 3) - #Other work can continue as usual here - exceptEoferror: + Print "\nwhy did you do a EOF on me?" - exceptshortinputexception, x: + Print "sh
3.1 Data types
Number (numeric) int, float, bool, complex (plural) int, expressed as a long integer and no long in Python2. There is no Boolean type in Python2, it is represented by the number 0 flase
String (string) the strings in Python are enclosed in single quotation marks (') or double quotation marks ("), and use backslashes (\) to escape special characters.
3.2 Data Structureslist, denoted by [], lists can be used in many ways
Reply content:Which is the hardest programming language?
Not C + +, not Lisp, but
your first language.。
Where is the hardest language?
Getting started is the hardest.
For example, the following code:
print"hello world!"As a slowly starting from Python, learning for nearly 2 years, I share the following, looking at rather than fraught.
1. Quick Start
The Dive into Python
/ http
Woodpecker.org.cn/divei
(understanding), Dictionary comprehensions Assignment: Solve the Python tutorial(Tutoring) questions on Hackerrank. These should get your brain thinking on Python scriptingAlternate Resources: If Interactive(interactive) coding isn't your style of learning, you can also look at Thegoogle Class for Pyth Mnl It is a 2 day class series and also covers some of the pa
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.