Modifier between% and the conversion character
-, left alignment flag, default to right alignment
+, display numeric symbol
0, 0 padding
A number that specifies the minimum width
. A decimal point, followed by the number of
WedgeIf there is a function, the implementation returns a larger value in two numbers:def my_max (x, y): m = x if x>y else y return mBigger = My_max (10,20)Print (bigger)Before I told you to return the results back, did you do it? But have you
Global variables
Global variables can be accessed directly in the function#-*-Coding:utf-8-*-__author__ = "MuT6 sch01ar" name = ' John ' def Test (): print (name) test ()Run resultsBut the value of the global variable (number, string) is not
function parameters in the actual application process is also relatively broad, such as in the registration, some information to fill, some of the parameter types are required parameters, some variable parameters, some default parameters, and so on,
Glob uses the Unix shell rule to find a file name that matches a pattern. This module is available whenever the program needs to find a set of files in the file system that match the name to a pattern.Glob pattern rules are not the same as regular
It's simple to introduce a few this time, but be sure to return the value rule carefully.
1.resume of parameters
The resume function can continue to pass other parameters besides the first parameter, the following code:
Copy Code code as
Scores={}result_f=open ("Results.txt") for line in Result_f: (Name,score) =line.split () scores[score]= Nameresult_f.close () print ("The top scores were:") for Each_score in Scores.keys (): print (' name: ' +scores[each_score] + ' score: '
I. Programming paradigmProgramming ParadigmProgramming is a programmer with a specific syntax + data structure + algorithm composed of code to tell the computer how to perform the task of the process, a program is a programmer in order to get a task
Python scope
Python no block-level scope to see the C language code:
#include int main () { if(20) { int0; } printf ("i =%d", i); return 0 ;}In this code, if clause introduces a local scope, the variable i exists
In this paper, the use of functions in Python programming is described in detail, which has a good reference value for the study of Python program design. The specific analysis is as follows:
First, the definition of the function:
Python uses the
To illustrate the thread synchronization problem, we must first describe the two features of Java threads, visibility and orderliness. Data Interaction cannot be directly transmitted between multiple threads. Interaction between threads can only be
Python phone book management example
#! /Usr/bin/env python # coding = UTF-8 # manage the phone book. you can add, delete, modify, and query user information. import cPickle as p class Telephone: def _ init _ (self): ''' constructor ''' def
Python day 1,
I. Variables# Print ("hello world ")# Age = 18# Define a variable with two features: id, type, and value# Print (id (age), type (age), age) (view the variable type)# Name = "egon"# Print (id (name), type (name), name)# Variable naming:#
1, the use of the collection:Operation #1, Collection: List_1 = [1,4,5,7,3,6,7,9]list_1 = set (list_1) #创建集合list_2 = set ([ 2,6,0,22,66,8,4]) print (List_1,type (list_1), list_2) print (List_1.intersection (list_2)) #取两集合的交集print (list_1.union
CodingPython2
The default encoding for python2.x is ASCII
The file at the beginning of the code statement is to tell the program to explain the codes, in what encoding format to read this code into memory, because in memory, this code
JavaScript One, no block-level scope in JavaScript
A brace is scoped to a block-level scope, and block-level scopes exist in Java and C #
function Main () { if (1==1) { var name = ' seven '; } Console.log (name);}
Introduction to the first knowledge of PYthon1.1 pythonThe founder of Python is Guido van Rossum (Guido van Rossum). During the Christmas of 1989, Guido van Rossum to spend time in Amsterdam, determined to develop a new script interpreter, as an
Use an example to familiarize yourself with the basic operation of a file: create a file, read a file, modify a file, delete a file, rename a file, determine whether a file exists1 " "2 Write a table of employee information that can be
1. Scope1.1 ScopesCode 1If 1 = = 1: name = ' Alex ' for I in range: name = iprint (name) # java/c# can not # Python/javascript can # Python No block-level scope inCode Listing 2: Functionsdef func (): name = ' Alex ' Print (name)
http://www.cnblogs.com/wupeiqi/p/5649402.html Five words take care of JavaScript scopesfrom javascript = = Pyhon Scope Almost consistent __:one, "no block-level scope in JavaScript"There is a block-level scope in Java or C #, which is: curly
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.