Address copy, data copy
#-*-Coding;utf-8-*-
Copy the
data from one list to another list #list copy "". The
core is a shallow copy or a deep copy (address or data) "" "
sourcelist = [11,333,444,555,6,7,6]
print sourcelist
copy2 =
In test1.py, when the denominator is 0, the calling system exits
#!/usr/bin/python
Import SYS
def division (a=1, b=1):
if b==0:
print ' b eq 0 '
sys.exit (1)
Else : Return A/
b
In test2.py, use the Try ...
First, the use of the packageNote: In Python2, the package must have a __init__.py file, and even if there is no error in Python3First Import Package: 1. Create a namespace based on the __init__.py file under the package2. Execute the code for the __
The enumerate () function is used to combine a data object that can be traversed (such as a list, tuple, or string) into an index sequence.Indexes and data are listed at the same time, typically used in a for loop.Enumerate(sequence, [start=0])
In Python, with can significantly improve code-friendliness, such as:With open (' a.txt ') as F:Print F.readlines ()For our own class can also use with, as long as the class to add two function __enter__, __exit__ can:>>> class A:def __enter__ (self)
#!/usr/bin/Env python#-*-coding:utf-8-*-# Author:DaShuang.Gu" "Requirements:Buyers1. Product information exists in the file2. Purchased goods, Balance records. The first time you start a program, you need to record your salary, and the second time
# Set Set# collections are similar to lists, tuples, and can store multiple data, but the data is not duplicated# The Collection object also supports Union (union), intersection (intersection), Difference (poor) and sysmmertric_difference (symmetric
What can I do with python? Can do daily tasks, such as automatic backup of your MP3, can do website, many famous websites including YouTube is written by Python, can do online game backstage, many online game backstage are developed by Python. It's
or copy it, https://www.cnblogs.com/yan-lei/p/7828871.html from here.Python code in one module gains access to the code in another module by the process of importing it.Two concepts:module: Used to organize Python code (variables, functions, classes)
1. Click on this computer to enter the top-most folder window:%appdata%2. Press ENTER to jump to the following directory, create a new PIP folder3. Create a Pip.ini file4. Open the folder, enter the following, close (note: The source image can be
1.How is arguments passed–by reference of by value?2.Do know what list and dict comprehensions is? Can you give an example?3.What is PEP 8?4.Do use virtual environments?5.Can you sum all of the elements in the list, what about to multuply them and
1.if __name__ = = = ' main ' functionThe code under this function can run only when the file is running. If the current file is imported as a module by another file, the code under the function will not be executed. The 2.__init__ method uses the
I. Interacting with usersInputPython2: What type of data is entered by the user and stored for what type of data. For example, the input number is stored as an integer, and the input symbol is stored as a string type. Raw_input converts all input
First, create a collection1. Featuresto store different elementsDisorderedImmutable types (numbers, strings, tuples)2. Create a CollectionS=set (' Hello ')Print (s)S=set ([' Alex ', ' Alex ', ' SB '])Print (s)s={1,2,3,4,5,6}3. Basic usage of sets(1)
In Python, comparisons can be made between objects, either by = = or by using is. But what is the difference between them?
is a comparison of two instance objects that are not exactly the same, they are not the same object and occupy the
Python three ways to run interactive interpreterEnter Python3 into the python interactive interpreter input exit () exit the interactive interpreter at terminal inputCommand-line scriptingCreating a Python script to execute a program through a
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