1. 字符串变量
# 注意引号的配对
a = "Hello, welcome to Python"
print("The string a is:", a)
print()
# 占位符
print("The length of this string is %d" % (a, len(a)))
print()
print("The type of a is", type(a))
The string a is: Hello, welcome to Python
The length of this string is 24
The type of a is
a = "Hello, welcome to Python"
print("The first character of a is %s" % a[0])
print("The first five characters of a are %s" % a[0:5])
print("The last character of a is %s" %a[-1])
print("The last two characters of a is %s"%a[-2:])
print("The last character of a is %s"%a[len(a)-1])
The first character of a is H
The first five characters of a are Hello
The last character of a is n
The last two characters