摘要:(字串) String 應用
hello='abcdefghijk'
print hello[6:10] #取Str 第6位到第9位 (不含第10位)
print hello.upper() #Str 內容會轉為大寫
print len(hello) #Str長度
print hello.zfill(20) #Str 回傳以 0 塞滿 width 的新字串 例:000000000abcdefghijk
print hello.rjust(20,'#') #回傳將 str 在寬度 width 向右對齊的字串, fillchar 為填充字元,預設為空格 例:#########abcdefghijk
print type(hello) #列印變數型別
#判斷變數是否為字串
if(isinstance(hello, str)): #Python 3.# Python 2.# 語法 isinstance(s, basestring)
print True
else:
print False