First, common functions1.input functionThe value received by the input () function is all string type, and if you want to compare it with the int type, you must use INT () to convert the string to int type to compare2. Print () function# Print (1/2)#
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)
Select Sort:Select sort (Selection sort) is a simple and intuitive sorting algorithm . It works as follows. First find the smallest (large) element in the unordered sequence, place it at the beginning of the sort sequence, and then continue looking
#文件读写# r can only read can not write, and the file must exist, W can only write can not read, a can only write unreadable# w+ is read-write mode, empty the original file contents# r+ is a read-write mode, without emptying the original file contents,#
defBubble_sort (L):"""design ideas: From the previous traversal of the list, each time the selection of the list of two numbers to compare, if it does not conform to the collation of the rules, then the largest (smallest) element will be like a
1, File encodingpython default encoding, Python2 defaults to ascii,python3 default to Utf-8 So, Python3 supports Chinese by default. Import sys>>> sys.getdefaultencoding () #显示python默认编码 'utf-8'2, 2, file Operation The pointer moves through the read
Using the Jieba library for Word segmentationInstall Jieba don't say, own Baidu!Import JiebaTurn the title participle and switch to listSeg_list = List (Jieba.cut (Result.get ("title"), Cut_all=false))All headings are connected using spaces to
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.
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 (
Job One :Output directory, you can choose to enter the directory, can be rolled back, launched!
#conding: UTF8Menu = {' Beijing ': {' Changping ': {' Shahe ': {' Changping MCH ',}},' Haidian ': {' Haidian District ': {' Haidian District
DirectoryFirst, IntroductionIi. three ways to serialize DjangoThird, serialization error message
First, IntroductionAbout serialization in Django the primary application of data retrieved in the database is returned to the client user, and
1, Shopping Cart Applet
Demand:
(1), after starting the program, print all the product list, the user entered the wages(2), allow users to purchase goods according to the product number(3), the user buys the goods, the balance is
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]:#
If you want to turn an instance of a class into str, you need to implement a special method __str__ ():class Person (object): def __init__ (self, Name, gender): = name = gender def__str__(self): return '(person:%s,%s)' %
Use of Django Ajax and djangoajaxIntroduction:
AJAX = Asynchronous JavaScript and XML (Asynchronous JavaScript and XML ).
AJAX is not a new programming language, but a new method that uses existing standards.
AJAX is the art of exchanging data with
Select sorting-Python implementation and python implementationSelect sort:
Selection sort is a simple and intuitive sorting algorithm. It works as follows. First, find the smallest (large) element in the unordered sequence, store it to the starting
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 -
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