Reflection:1. The module can be imported in the form of a string1.1. Single-Layer Import1 __import__ (' module name ')View Code1.2. Multi-layer Import1 __import__ (' list.text.commons'# If you don't add fromlist=true, only the list directory will
#需求Writing the Login interface-Enter user name password-Show welcome message after successful authentication-three times after the wrong lock#脚本目录[Email protected] opt]# tree ├──account_lock.txt├──accounts.txt└──login.py0 directories, 3 files#脚本文件#!/
Object-oriented programmingPython is OOP, usually, each object definition corresponds to some object or concept in the real world a nd the functions that operate on that object correspond to the ways Real-world objects interact.In Python, every
files, folders in Python (file manipulation function) operation requires an OS module and a shutil module. Get the current working directory, that is, the directory path of the current Python script work: OS.GETCWD ()Returns all files and directory
1. New class and Classic classIn Python 2 and previous versions, classes derived from any built-in type (as long as a built-in type is located somewhere in the class tree) are "modern class", and All "modern class" attributes are obtained, and
Python Read and write filesPython Read and write files1.openAlways remember to call the close () method of the file object after opening the file with open. For example, you can use the Try/finally statement to ensure that the file is closed at last.
Random.randomRandom.random () generates a 0.0~1.0 floating-point numberRandom.uniform (word meaning: uniforms, uniforms, uniform, same)Random.uniform (parameter 1, parameter 2) This function requires a parameter that generates a floating-point
1#When there is an inheritance relationship, the same method exists in the two classes, how to execute the method of the parent class, and the Super2classC1:3defF1 (self):4Print('c1.f1') 5 6 7classC2 (C1):8defF1 (self):9#actively executing the F1 of
site"This module is automatically imported during initialization. The automatic ImportCan be suppressed using the interpreter ' s -s option.Importing this module would append site-specific paths to the module search path and add a few builtins.
The Python standard library provides modules such as Urllib for HTTP requests, but its API is too slag. It was created for another era, another internet. It requires a huge amount of work, even covering a variety of methods, to accomplish the
Sometimes you need to use floating-point numbers in JSON, such as prices, coordinates, and so on. But the floating-point numbers in python are fairly inaccurate, such as the following code:Copy the Code code as follows:#!/usr/bin/env pythonImport
I. INTRODUCTIONParamiko is a module for remote control, which can be used to command or file the remote server, it is worth saying that the fabric and ansible internal remote management is the use of Paramiko to reality.Two. Use1. Download and
Tips for implementing the iterator in Python programming, python Summary
Yield implementation iteratorAs described in the introduction, to implement an iterative function, if you manually implement iter every time, next is a little troublesome and
Simple implementation of upgrading Centos Python2 to Python3, centospython3
1. Obtain the Python 3 package from the Python official website and switch to the/usr/local/src directory.
#wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz
2
Python -- about join and split, python -- joinsplit
. Join ()
Join splits the container object and connects the elements in the list with specified characters. Return a string (note: the elements in the container object must be of the character type)
Common django commandsDjango basic commands
This section mainly aims to help you understand some of the most basic django commands,Please remember them and exercise more1. Create a django project
django-admin.py startproject project-name
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