Python2
can be used MySQLdb
The code is as followsclasssqlObject):def __init__( Self):Try: Self. conn=MySQLdb.Connect(Host=DB_IP, user=Db_user, passwd=Db_password, DB=Db_name,) Self. Conn.set_character_set (' UTF8 ') Self. cur= Self.
Importurllib.requestImportjson,requests#urlib modules, not commonly usedURL ='http://api.nnzhp.cn/api/user/stu_info?stu_name= Small Black Horse'Res=urllib.request.urlopen (URL) Jieguo=res.read (). Decode ()#The return value is of type byte and
1. In the Python Foundation we talked about PYTHON2X is used Assic encoding and python3x is the UTF-8 encoding, the origin of the code and some rules.Assic code at the beginning of the American invention is only able to print English letters and
This series of tutorials is intended for individual learning notes, and if you want to browse may require other programming language basics (such as C), why? Because I write rotten ah, only I can understand!!
Module#1. The module allows you to
Tag: false represents method part LSE Pytho nbsp Boolean sequencePython3stringA string is an ordered sequence of charactersHow to represent a string:In non-annotations, all the parts enclosed in quotation marks are strings;' single quote ' double
1: First install the Python virtual environment;2: Start the virtual environment; \venv\scriptsRun Activate directly3: In a virtual environmentPip Install FlaskInstalling flask4:A minimal Flask application would look like
iteratorsAn iterative# an iteration is a repeating process that repeats one iteration at a time, and the result of each iteration is the initial value of the next iteration while True: # is simply repeated, thus not iterative print('===>' = [1
1, the identifier is composed of letters, underscores and numbers, and the number can not start12mytest ErrorMyTest toMyText (Large hump-type nomenclature)MyText (Small Hump-named method)My_test personally like this naming methodYou cannot use the
Subprocess of common Python modulesPython2 has a module commands, the module that executes the command, is obsolete in Python3, uses the subprocess module to replace the commands.Brief Introduction: Commands moduleThree common
Qgis can generally be developed in two languages, such as C + + and Python, while Python is portable, easy to learn, widely used, and highly developed in comparison to C + + development. Using Python development will greatly improve development
function definition:def (): function body return Parameters have non-optional parameters, and optional parameters, optional parameters are placed at the end of the parameter list, and you can specify default values for optional parameters. As
Below for you to share a Python read the CSV file and put the file into a list of the examples, with a good reference value, I hope to be helpful to everyone. Come and see it together.
As shown below:
#coding =utf8 "to read the CSV file and
Below for you to share a Python Delete non-empty folder instances, has a good reference value, I hope to be helpful to everyone. Come and see it together.
Generally delete files using the OS library, and then use Os.remove (path) to complete the
Below for you to share a Python file open and close Operation Command introduced, with a good reference value, I hope to be helpful to everyone. Come and see it together.
1. File Open and Close
In Python, using the Open function, you can open a
Below for you to share a Python get program to execute file path (recommended), with a good reference value, I hope to help you. Come and see it together.
1. Get the current execution main script method: Sys.argv[0] And _ file _
(1) SYS.ARGV
A list
This article mainly introduces the use of Python multi-thread event events, and now share to everyone, but also to make a reference. Come and see it together.
Objective
Small partners a,b,c around to eat hot pot, when the food is QI, the host said:
This article mainly introduces the Python folder traversal and file search examples, has a certain reference value, now share to everyone, the need for friends can refer to
The examples are as follows:
#-*-Coding:utf-8-*-#to find where to use the
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