···· FunctionConsists of a set of code that accomplishes a specific taskKeywords: defThe creation of the function:def function name (parameter list):Code (Implementation of the function)Def printhelloworld ():For I in range (10):print ' Hello world '
Os.path.dirname (__file__) returns the path to the script, but there are a few things to consider:1. The. py file must be actually present, and if executed at the command line, an exception is thrown nameerror:name ' __file__ ' is not defined2. When
single-line comment with #Multiline comment with three single quotes or three double quotation marks ' ' annotated content 'msg = "I love China" #在这里是给这一行代码加注释 print (msg) print (msg) #print (msg) ' Print (msg) ' Print (msg) 'basic input and output
Python is very common for files, such as we need to open a file to get the data, or create a file to change the datavi 1.txthello wordWe create a file called 1.txt, and then we need to manipulate the file1、对文件进行读 file = open("1.txt" "r") print
One, variable, constantVariables: used to store and tag information in memory for easy invocation, manipulation, and modification in the futureConstant: The amount that is fixed to the same size. Uppercase lettersNaming rules:1, composed of
Python * urllib_urlopen () Python urllib Library provides a Web page data from a specified URL address, which is then parsed and processed to obtain the desired data. One, Urllib module Urlopen () function: Urlopen (URL, data=none, timeout,
from random import randintimport threadingfrom time import ctime, sleepdata = [' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' h ', ' I ', ' J ']class mythread (threading. Thread): lock = threading. Lock () def __init__
Python3Meta-groupA Python tuple is similar to a list, except that the elements of a tuple cannot be modified .Tuples use parentheses (), and the list uses square brackets [].Tuple creation is simple, just add elements in parentheses and separate
Login interface and realize guessing number game
Enter User name password
Show welcome message after successful authentication
Guess the number game, guess three times
Three-time error after
Python applet Exercise Two small example of the adornerAdorner:Adorner is actually to add functionality to a program, but the program has been online or has been used, then can not be large-scale modification of the source code, this is not
def quick_sort (array,left,right): If left >= right : return low = left high = right key = Array[low] While left key: Right- = 1 array[left] = Array[right] While left Print out the results of each step and clearly
Demand:Let the user enter the user name password Authentication successful display welcome information after the error three after the exit program can support multiple users login (prompt, through the list to save multiple account information) User
These days to tune a multipart/form-data type of interface, encountered a small obstacle. Former colleagues have used the Urllib library to write a similar method to achieve, relatively long, want to change the time found not very good. Find on the
Reproduced:Http://www.jb51.net/article/100195.htmObjectiveStudents who have written object-oriented code in Python may be familiar with methods that __init__ ,__init__ run immediately when an object of the class is built. This method can be used
1./Floating-point division, even if the numerator denominator is of type int, also returns float type, for example, we use 4/2, return 2.02.//Integer division, based on the different combinations of numerator denominator, returns a difference in
This article is to share the content of Python practical function advanced, now share to everyone, the need for friends can refer to the content of this article
1.pyhton Assertion
How to add an exception parameter for an ASSERT assertion
This time for you to bring Python how to deal with the Dataframe field, Python Processing dataframe time field of attention to what, the following is the actual case, together to see.
During machine learning, CSV files are usually read through
This article mainly introduces the introduction of the use of the title () method in Python, now share to everyone, the need for friends can refer to the following
The title () method returns a copy of the first character of all words in uppercase
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