#!/usr/bin/env python #-*-coding:utf-8-*-function relateddef f1 (par,par2,par3= "OK"): #定义函数 with parameter, with parameter default value with return valueTryPrint ("This was function by%s%d%s"% (par, PAR2,PAR3))ExceptReturn FalseElseReturn Trueres =
A. py file is a module in which many functions can be defined, and functions can be loaded into a module. Modules also have Python built-in modules, and third-party modules, different modules can have the same function name and variable name, the
Opens the Excel file, returning the value of the first column in list formXlrd
defNewdbfind(): Spinfo= Xlrd.open_workbook(' dispose.xlsx ') Sh= Spinfo.Sheet_by_index(0)#返回第几页的对象 Spcodelist= Sh.col_values(0)Reading Excel files
Applications sometimes need to interact with the user in order to continue, such as user login. The use of input is the key to this scenarioScenario: Users need to enter a user name and password when logging in, if the user failed to login three
See on the http://usingpython.com/dl/animBanner.py, very fun, made a little change.#To SHOW STRING "I like you!" In the WINDOWS CONSOLEImportOSImport Time#Windows Console widthwidth = 79#Printedmessage = ["***** * ***** * * ***** *
Problem: Check the specified text pattern at the beginning or end of the string, such as checking the file extension, URL protocol type, etc.;Workaround: Use the Str.startswith () and Str.endswith () methods>>> filename='Spam.txt'>>>
The operation of files and folders in Python involves both the OS module and the Shutil module.To create a file:1) Os.mknod ("Test.txt") Create an empty file2) Open ("Test.txt", W) opens a file directly and creates a file if the file does not
1 #you need to import character encoding, or you will get an error if you encounter Chinese2 #Coding=utf-83 4 #1 Defining Variables5A = 106b = 27c = A +b8 Print(c)9 Ten #2 Judgment Statement OneScore = 90 A - ifScore>= 80 : - Print("very good")#
A summary of the review of the second day course1, the list can be deleted and changed, the tuple is not modifiable list, the string is not modifiable.2, the list, the tuple is ordered, the dictionary is unordered, the dictionary key is unique3.
1.>>> d = {‘x‘: ‘A‘, ‘y‘: ‘B‘, ‘z‘: ‘C‘ }>>> for k, v in d.iteritems():... print k, ‘=‘, v... y = Bx = Az = C2.>>> L = [‘Hello‘, ‘World‘, ‘IBM‘, ‘Apple‘]>>> [s.lower() for s in L][‘hello‘, ‘world‘, ‘ibm‘, ‘apple‘]3.def add(x, y, f): return f(x) +
Problem:There are two special cases in the function definition of Python, that is, the form of *,** appears.such as: Def myfun1 (username, *keys) or Def myfun2 (username, **keys) and so on.Explain:* Used to pass any of the parameterless parameters,
python--Exercise 37 of the methodology—————————————————————————————————————————————————————————————————————————————————————Sticky Notes pile up a table, write a reason———————————————————————————————————————————————————————————————————————————————————
Python-Based String explanation and python-Based String explanation
1. Python environment Configuration:
Python Official Website: https://www.python.org/
Pycharm http://www.jetbrains.com/pycharm/download
Install the SDK after the download. Check the
Python video lecture 5 (notes and answers to exercises after class) and python lecture 5
Two days ago, I was lazy and didn't insist. I started today and hoped to stick to it,
Today we are mainly studying data types. For python, data types mainly
Day9 network programming and day9 Network Programming
OSI (Open System Interconnect), that is, Open System Interconnection.
International Standardization Organization (ISO)
OSI Layer-7 model:
TCP/IP protocol:
TCP three-way handshake:
TCP
Python learning notes-functions and python learning notes
1. Define the function:
In Python, define a function to usedefStatement, write the function name, parameters in parentheses, and colons in sequence:Then, write the function body in the indent
Using Python for data analysis (6) NumPy basics: vector computing and pythonnumpyVectoring refers to replacing the loop with an array expression to manipulate each element in the group.NumPy provides a universal function (ufunc function) that
Python Base Five, pythonbasefive
// 8 day)
38. In python, it is oop.
Class Baskball:Def setName (self, name ):Self. name = nameDef kick (self ):Print ('My name is % s' % self. name)Baskball = Baskball ()Baskball. setName ('baskball ')Baskball. kick (
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