First, create a dictionary:D = { "name": "Morra", #字典是无序的 "age": " Gender": ' m '}a = Dict () b = Dict (k1=123,k2= "Morra")Second, dictionary commonly used: modify or add a dictionary:Other common methods:
Len (a)
1. IteratorsIterators are a way to access the elements of a collection. The iterator object is accessed from the first element of the collection until all of the elements have been accessed and finished. Iterators can only move forward without going
Re. Sub (pattern, repl, string, count=0, flags=0)Re.sub meaning, function, function is:For the input string, use the regular expression (the powerful string processing function) to implement (relatively complex) string substitution processing, and
1 Import OS 2 ' f:/save_file/seminarseries/ ' 3 for inch Os.walk (path): 4 Print (Root)This prints out two paths that represent the path currently being traversed , the first is the path to the current directory folder, and the other is the
How to perform cross-browser testingIf we use Selenium webdriver, we can automatically run test cases on different browsers such as IE, Firefox, Chrome, and so on.To be able to execute test cases simultaneously on different browsers on the same
Topic:Use Python to generate a 4x4 two-dimensional array and rotate it clockwise by 90°The source code is as follows:Import randomdatarow=[]data=[]for i in range (4): for j in range (4): datarow.append (Random.randint (10,80)) data.
Let's start by identifying the requirements:Write a registered program, enter USERNAME,PASSWD,CONFIRMPASSWDAfter successful registration, the prompt registration is successful, the program exits, requiring the user name cannot be repeatedThe number
TextWrap formatting text by adjusting the position of line breaks__all__ = ['textwrapper'wrap'Fill 'dedent' 'indent ' Shorten ']Fill () Adjust line breaks, each line shows the given width""" Asdsafsdkafsadfsadfasdsadfasdfsad """ Print (text) Print (
Sys.argv[] is used to get command line arguments, Sys.argv[0] represents the code itself file path, so the parameters starting from 1, the following two examples illustrate:1. A simple example of using sys.argv[]:The following is the sample1.py file:
What if you want to use Python for multiple inputs like the ACM topic? Because in Python I now only find the input function to enter, only the input string, but input has a function to remove the space, so you can use the method of processing the
In Python, there are also global variables and local variables, but as far as I know, if a variable defined in the if is a global variable that falls down, there is also a function definition and return in Python, usually defining a function:def
Use native Python developed Web server, entry level!#!/usr/bin/python#-*-coding:utf-8-*-ImportOs#The OS module in the Python standard library contains common operating system featuresImportRe#Introducing Regular Expression ObjectsImportUrllib#used
Create a two-way queueImport COLLECTIONSD = Collections.deque ()Append (add an element to the right)Import COLLECTIONSD = Collections.deque () d.append (1) d.append (2) print (d) #输出: Deque ([1, 2])Appendleft (add an element to the left)Import
Python uses sys.argv[] to implement external parameters from the programSYS.ARGV returns a tuple, the first element of the tuple is the program itself, and the second element is followed by each parameter that we specify by entering. That is, the
Li = [33, 2, 10, 1,564,880,8,99,51,3]# for I in range (Len (LI)-1):# current = Li[i]# next_value = li[i + 1]# if li[i] > li[i + 1]:# temp = Li[i]# Li[i] = li[i + 1]# Li[i + 1] = Temp# Print (LI)## for I in range (Len (LI)-2):# if li[i] > li[i + 1]:#
In the previous chapter, we learned some basic methods of Python multi-process programming: Using the process, Pool, Queue, Lock, pipe, and other classes provided by the cross-platform multi-process module multiprocessing, to achieve child process
Ubuntu16.04 sets python3 as the default value, and ubuntu16.04python3
Ubuntu uses Python 2.7 By default, so the Python package is installed with Python 2.
Use alternativesMechanism Change py3 to default.
Execute in shell:
sudo update-alternatives -
Python small topic exercises, python ---
Job 1:
With the * dictionary * output directory, you can select a directory to enter. You can roll back and exit!
# Conding: utf8Menu = {'beijing': {'changping ': {'shahe': {'changping maternal and
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