1.python basic types are: numbers, strings, lists, tuples, dictionaries.
(1) The number type has the following types:
int (signed integral type)
Long (longer integer [can also represent octal and hexadecimal])
Float (float type)
Complex (plural)
(2) A string: A String or Series (string) is a series of characters consisting of numbers, letters, and underscores.
(3) List: A list is the most commonly used Python data type, which can appear as a comma-separated value within a square bracket.
(4) Tuples: A 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.
(5) Dictionary: A dictionary is another variable container model and can store any type of object. The key must be unique, but the value does not have to be.
2.Python loops often have a for loop and a while loop.
The above example code and the calling code are as follows:
he.py
#Coding=utf-8#Basic TypedefShow ():#Digitalage=10Print("Age :"+Str (age))#stringUname="Tom" Print("uname:"+uname)Print("The first charset of uname:"+uname[0])#Listli1=["Joyet1","tom1"] Li1.remove ("tom1") Li1.append ("Mike1") Li1.insert (1,"yy1") Li1num=Len (li1)Print("li1 Length:"+str (li1num))#list for loop forXinchLi1:Print("the list values are:"+x)#Meta-groupLi2= ("Joyet2","Tom2") J=0 whilej<Len (li2):Print("the tuple values are:"+Li2[j]) J+=1#Dictionaryli3={"UID":"1","uname":"Joyet"} Print("Dictionary uid:"+li3["UID"]) forDickey,dicvalueinchLi3.items ():Print("Key:"+dickey+", the value is:"+dicvalue)
Calling code:
from Import *>>> Show () Age:uname:tomthe First CharSet of uname:tli1 length:3 list values are: Joyet1 List value is: Yy1 list value is: Mike1 tuple value is: Joyet2 tuple value: Tom2 dictionary uid:1key:uid, Value:1key:uname, Value: Joyet> >>
Basic types of Python basics, looping