First, WGet official website downloaded to the local
Entry home directory:cd ~
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgzDownload to local
Decompression is moved to /usr/lcoal:
tar -zxvf Python-3.6.3.tgz
mv Python-3.6.3 /usr/local/
Installation dependency:
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
Delete old Python soft connection
rm -rf /usr/bin/python
Try to compile and install Python:
cd /usr/local/Python-3.6.3/
To configure:
./configure
Compile:
make
Installation:
make install
Failure to find suitable compiler:
configure: ...
Supplement: there is no introduction to the usage of with open in this book.
If you have a dream, you need to realize his “Python file read and write, and then use the with open statement”.
Reading and writing files is the most common IO operation. Python has built-in functions for reading and writing files, and its usage is compatible with C.
Before we read and write files, we must understand that the function of reading and writing files on disk is provided by the operating system. Modern operating systems do not allow ordinary programs to operate disk directly. So, rea...
Just take the big brothers and get it ready.
Rollen Holt 《About Python file operation “
AllenW 《PythonRead and write files
—————————————Rollen Holt—————————————
pythonThe operation of files and folders (file operation functions) involves OS modules and shutil modules.
Gets the current working directory, the directory path of the current Python script: os.getcwd ()
Returns all files and directory names in the sp...
CampThere was a lot of python2 coding.
Understanding the encoding of pyhon2
python2There are only two kinds of string types:Type STR: B'xxx'That is, the str type is the encoded type, and Len () is calculated bybyte.Unicode type: len (), calculated by Unicode character.
python2Open file read string is STR type, without encoding parameter.Recommended reading and writing files under python2codecs packageCodecs.open, codecs.write can specify encoding.
python3Coding
python3There are two kinds of string types:Type STR: u'xxx'The str type is the uncoded Unicode. Pay attention to the distinctio...
socketRealization
serverend
import socket
import subprocess
import struct
import json
# Buy a mobile phone
phone = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Insert phone card, port range 0-65535
# Look at the usage state of the port and enter netstat -an |findstr 8080 on the command line.
phone.bind(('127.0.0.1', 8081))
# Open the machine
phone.listen(3) # The number of semi connected pools is limited.
print('server start...')
# Waiting for phone connection request
while True: # Connection cycle
conn, clinet_address = phone.accept()
print(conn, clinet_address)
while ...
One, reflectionVariables in reflection classVariables in reflection objectsVariables in reflection moduleReflect variables in this document1、Definition: use the variable name of string data type to get the value of this variable.For example:Name= 'xiaoming'
print(name) # xiaoming
print('name') # name
Usually we want to get'xiaoming'This value is to be obtained by name, but if you want to use a string'name' Get this value?Reflection is needed.2、The scene of reflection application is to convert the received string to the name of the variable.1,input
If the user input is a, the...
pythonString, string manipulation functions and string related operations
String introduction
pythonString representation
PythonIn addition to processing numbers, strings can also be processed.
>>> 'spam eggs'
'spam eggs'
>>> 'doesn/'t'
"doesn't"
>>> "doesn't"
"doesn't"
>>> '"Yes," he said.'
'"Yes," he said.'
>>> "/"Yes,/" he said."
'"Yes," he said.'
>>> '"Isn/'t," she said.'
'"Isn/'t," she said.'
The output format of the string is the same as the input, wrapped in apostrophes, and the apostrophes and other special characters...
Python Built in string method (Collector only)
method
Character string
string
python3.x
python
4.7k It takes 44 minutes to read and read.
5
String processing is a very common skill, but Python built-in string method is too many, often forgotten, in order to facilitate quick reference, according to Python 3.5.1 to write an example of each built-in method and categorize, for everyone to index.PS: You can click the green header in the overview to enter the corresponding category or quickly index the corresponding method through the right sidebar article cata...