Standard data types
Number
Ten21.66= false;print (type (Boolvar));
Type () types detection
Isinstance () type match
Modify the above code
intintbool));
String
str ="Hello Jiao"; # start at index 0 to indexBefore =-1 (contains index=0 does not contain index=-1"Index=-1 is the last character of the string ") print (str[0: -1]); # Hello jia# starting from index 0 to indexBefore =4 (contains index=0 does not contain index=4) print (str[0:4]); # hell# start from index 6 to end (contains index=6) print (str[6: ]); # jiao# output two times string print (str*2); # string concatenation print (str[0:5] +"World !!!");
The string hollow lattice is not omitted.
Escape character Valid
The string method will only return the modified string, the original string variable will not be changed (that is, you cannot modify a character in the string, error)
Lists List
List1 = ["Tom","Jimy",890,22.1,"haha"];p rint (list1);p rint (Type (list1));p rint (list1[0]);p rint (list1[0: -1]);p rint (List1*3); List2= ["Hello Jiao"];listall= List1 +list2;# Delete list element listall[1:2] =[];p rint (listall);
List methods and string methods are broadly consistent, note that the deletion of list elements must be written
list[n:n+1] = [];
It's not possible to write anything else. You might replace this element with a list, an empty string. Because: the elements in the list can be modified.
Tuple tuples
Tuples are similar to lists, declaring lists with [], declaring tuples with ()
Immutable elements in a tuple cannot be modified.
The above sentence is a bit around, for example:
TU1 = ("fftu", ["jiao " ]); tu1[-1[0"fftu";p rint (TU1);
The last element in the tuple is a list that can be modified, even as an element of a tuple.
However, if you modify other elements, you will get an error.
In Python, a variable is not declared, and an object is created when the value is assigned.
To delete an object reference
Del Num1, num2;
python--Data types