Python accesses substrings and intercepts strings using square brackets []. The syntax for intercepting strings is as follows:
var1 = 'Hello World! '
var2 = "Runoob"
print ("var1[0]: ", var1[0])
print ("var2[1:5]: ", var2[1:5])
Copy the code
Results: VAR1 [0]: H VAR2 [1:5]: UNOO
For example, a= 1234 B = 567 c=a+ B print©
The result c is 1234567
Print (” MY name is %s this year %d!” My name is Xiao Hei and I am 12 years old!