Built-in functions#内置函数1, ABS take absolute value‘‘‘n = ABS (-1)Print (n)‘‘‘2, all of the true is Truen= all ([1,2,3,0]) print (n) False3, any as long as there is a true, it is truen = any ([0,1])Print (n)True4, #bin () Decimal Exchange binaryPrint
1. Use%s to indicates ="welcome%s to login%s"%("Alex"," China")Print(s) s="welcome% (name) s to login% (city) s"%{"name":"Alex"," City":"Wuhan"}Print(s)s = "%10s is%+10d years old"% ("Alex",-10)Print (s)Alex is-10 years oldExplanation: The first
#升级版本Yum-y install Gcccd/optwget Http://python.org/ftp/python/2.7.6/Python-2.7.6.tgztar XF python-2.7.6.tgz./configure-- prefix=/usr/local/python2.7 CD python-2.7.6./configure--prefix=/usr/local/python2.7 make && make INSTALLMV/
Python functionsFirst, the functionA function is a group of statements that accomplishes a particular function, which can be used as a unit and give it a nameThe function name can be executed multiple times in different places of the program (this
Official Notes :Super (type[, Object-or-type])Return the superclass of type. If thesecond argument is omitted the Super objectReturned is unbound. If The second argument is an object,isinstance (obj, type)Must be true. If The second argument is a
First, open the file:Syntax: File_obj=open (Filename,mode)The open () function returns a file object where filename is the file name and if the file does not exist, a file is created, and mode indicates how the file is opened.Common mode values:
Find a very useful libraryFaker, the effect can generate a variety of random datanew version to use PIP install fake-factory instead of direct pip install fakeGit:https://github.com/joke2k/fakerDocumentation:
When you introduce a package in Python, you get an error:Import UnitTestImport SmtplibImport timeImport OSImport SysImp.reload (SYS)Sys.setdefaultencoding (' Utf-8 ')Attributeerror:module ' sys ' has no attribute ' setdefaultencoding '
#需求
Develop a shopping cart program
Ask the user to enter a salary and then print the Shopping cart menu
Users can constantly buy goods until the money is not enough
In the menu, users can choose to print their own purchased
1.1 Mounting Module1.1.1 installing third-party modulesThe third-party library will be Python official pypi.python.org website registration, to install a third-party library, you must first know the name of the library, you can search on the
Using Python to manipulate Excel files requires a third-party library: OPENPYXL, which performs pip install OPENPYXL installation1. Import the OPENPYXL moduleAfter importing the OPENPYXL module, use its Load_workbook () method to open an Excel file
Suppose you now have such a SQL log:SELECT * from Open_app WHERE 1 and ' client_id ' = ' a08f5e32909cc9418f ' and ' is_valid ' = ' 1 ' ORDER BY id DESC limit 32700,10 0;# time:160616 10:05:10# [email protected]: SHUQIN[QQQQ] @ [1.1.1.1] id:46765069
When summarizing Python objects and references, it is also possible to understand the deep and shallow copies of Python in fact.In Python, an object's assignment is actually a reference to the object. That is, when you create an object and then
What is DictWe already know that list and tuple can be used to represent sequential collections, for example, the name of the class:[' Adam ', ' Lisa ', ' Bart ']Or the test results list:[95, 85, 59]However, to find the corresponding score according
For example:#-*-Coding=utf-8-*-import jsondata = []with open (' Data.json ') as F: For line in F: data.append (Json.loads (line) strkey = ' evaluation ' strkey = Strkey.decode (' utf-8 ') # python default is Unicode encoding, no transcoding,
Due to functional and procedural dependencies, the python on CentOS needs to be upgraded from 2.6 to 2.7, and some of the problems encountered are recorded as follows:After installing 2.7, change the original/usr/bin/python to/usr/bin/python26 and
Frist Django app-4. Improved View and fristdjango
The previous article has completed the basic functions of polls. Next, we will improve the remaining vote functions and use generic views to improve the view processing of requests. Contains simple
Python translation [sorting advanced], python translation sorting
The Python list built-in sort () method is used for sorting. You can also use the python built-in Global sorted () method to generate a new sequence for iterative sequence sorting.
1)
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