Python字符串:
在Python中的字符串被肯定爲一組連續的字符在引號之間。 Python容許在任何對單引號或雙引號。串的子集,可使用切片操做符可採用([]和[:]),索引從0開始的字符串的開始和結束(-1)。python
加號(+)符號的字符串鏈接操做符,而星號(*)表示重複操做。例如:markdown
#!/usr/bin/python
str = 'Hello World!'
print str # Prints complete string
print str[0] # Prints first character of the string
print str[2:5] # Prints characters starting from 3rd to 5th
print str[2:] # Prints string starting from 3rd character
print str * 2 # Prints string two times
print str + "TEST" # Prints concatenated string
這將產生如下結果:spa
Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST「code