, request to download the corresponding files until the ftp file download is complete, exit FTP and client.
Note: Three kinds of transmission protocol implementation process can refer to the relevant reading at the end of the text, some of the contents such as file path and filename are hard-coded, follow-up can be modified.2 Server Establishment Process /Server SetupThe main steps of server Setup are:(1) Instantiate bootp,tftp,ftp three servers;(2) Turn on three threads, run the server sep
the Chinese string in Python into Utf-8, then encode to GBK code
Data.decode (' Utf-8 '). Encode (' GBK ')
3. If you are reading a CSV file, in turn:
Data.decode (' GBK '). Encode (' Utf-8 ')
Solution Solutions1. Scenario One: Encoding the string conversion (this is too cumbersome, not recommended) # coding:utf-8import CSVF = open ( "Xieru1.csv", ' WB ') writer = Csv.writer (f
Python basics 3: re Regular Expressions and python Regular Expressions
A regular expression (or RE) is a small, highly specialized programming language embedded in Python that only matches characters.
1. Character Type:
Common characters and metacharacters;
1) common characters: Most characters and letters will mat
condition for multiple values, you can use the following form:if judgment condition 1: Execute statement 1... elif judgment Condition 2: EXECUTE statement 2... elif judgment Condition 3: EXECUTE statement 3... else: EXECUTE statement 4 ... Examples are as follows:The output is:>>> RoadmanSince Python does not support switch statements, multiple condi
First, brief"Format string"-each time you use "or" to refer to some text, you create a string. A string is the way the program presents information to people.Second, the Code1 #!usr/bin/env python2 #-*-coding:utf-8-*-3 4 #Author:xixihuang5 #Date:2016/08/31 09:52 AM6 #Desc: Exercise 5: More variables and printing7 #type more variables and print them out. This time we will use something called "format str
assignment exception will be thrown.>>> A, B, C =Traceback (most recent ):"" in 2 values to unpackNew assignment unpacking features updated in Python3.0: Use the * operator to save the arguments in the form of a list.>>> A, b, *c = 1,2,3,4,5,6,7,8,9>>> a,b,c (1, 2, [3, 4, 5, 6, 7, 8, 9])Assignment of a variable to a multivariable-------chained value>>> A, B = 1,2>>> A, B (1, 2)Expression operators (+ 、-、
, directly enter -10, the default corresponding parameter days
res = datetime.datetime.today () + datetime.timedelta (hours = -10, minutes = -20, seconds = -15)
print (res.date ()) # get date only
print (res.time ()) # only get the time
print (res.timestamp ()) # timestamp
print (res.strftime (‘% Y-% m% H:% M:% S‘)) # get the format time
map, filter module
# The loop helps you call the function
import os
import time
def makir (dir_name):
if not os.path.isdir (dir_name):
os.mkdir (dir_
(foo)
only foo equals Foo.read (), the function of the read function is to read a string from an open file.
It is said that some people do not like to read the file!! Why is that?
Because:
The mechanism of Read () is to read the contents of a file into memory, not meet the needs of everyone
So there's a readlines () load all the content into memory once, and split by row, compositing list
ReadLines ()
Foo = open (' Test ', ' r ') SS = Foo.readlines () print (ss)
[' a\n ', ' bb\n
Section 1 Python also has a good data type: String 2. A String is a String written in ''or" ". 3. Set the brian variable to" Always look on the bright side of life.! "[Python] # Set the variable brian on line 3! Brian = "Always look on the bright side of life! "Section 2 1 Exercise 1 set the variable caesar to Graham 2
Python full stack Development 5. Several Common sorting algorithms and the data structure provided by the collections module, pythoncollections
During the interview, I often encounter some questions about the sorting algorithm. Here, I simply listed several of the most common sorting algorithms for you to learn. Maybe the interview will be useful in the future, the second half of this article introduces the
Chapter 5-dict objects
Similar to the map of C ++ STL in Python, dict is a ing container (key-> value), but the implementation principle is different. Because python uses a large number of structures such as dict (such as the Intese mechanism of string objects) and has high efficiency requirements, Python does not use
characters test='Alex'v=test.strip ('A')Print (v)Output: Lex1.5 Upper ()Convert lowercase letters to uppercase test='Alex'v=test.upper ()print(v)Output: ALEX1.6 Lower ()Convert uppercase letters to lowercase test='ALEX'v=test.lower ()print(v)Output: Alex2. Special usage2.1 Gets a value from a string according to the index test='Alex'v=test[0]print(v)-------- A2.2 Gets a value of a string based on the range test='Alex'v=test[0:3]print(v)------
#!/usr/bin/python#-*-coding:utf-8-*- fromCollectionsImportdequedefz69 ():" "card Tricks (1) magician, the top one is black A, the 2nd time from the top to the next 2 in the bottom, and then open is the black K, and then from the top to the next number 3 is placed at the bottom, is the black Q, the K number of K Zhang, turn, to get black a~1; Ask the original card sequence" "SS=13D= Deque (Range (1,ss+1)) F=
on the recruitment website, and then measure the eligibility of the Training organization Course catalogue. As for those who don't even have a syllabus, Koko.2. Teaching InstructorMany training institutions in order to save costs, low-cost hire novice python developers to do the lecturer, or let other academic instructors now learn Python as a lecturer, delay countless students. It is also the key to under
1, block-level scope
Would you like to run the following program at this time with output? Will execution succeed?
#块级作用域
If 1 = 1:
name = "Lzl"
print (name) for
I in Range (a): Age
= i
print (age)
Let's take a look at the execution results first.
c:/users/l/pycharmprojects/s14/preview/day8/scope/main.py
Lzl
9
Process finished with exit code 0
Code execution succeeded, no problem; in java/c#, execution of the above code prompts Name,age to be undefined an
return, enter the assembly name, and then return to the installation:
Anaconda
Anaconda is currently the best Python autocomplete and syntax hint plugin in Sublime 3, and provides "jump to Definition", "Find and use", "Show Documents", "Auto Rename" functions of plugins in the IDE.
Djaneiro
Provides support for Django
#题目: Enter three integers x, y, Z, please put these three numbers from small to large output.#a = input (' Please enter an integer: \ n ')##B = input (' Please enter an integer: \ n ')##c = input (' Please enter an integer: \ n ')##L = [A,b,c]##L.sort ()##For i in L:#print (i)Method 2:l= [] forIinchRange (3): I= Input ('Please enter a number: \ n') l.append (i) l.sort ()Print(l)Use a list to express what you can do at once."
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.