Strings can be subscripted (indexed),subscriptedindexed,#like in C,
文章由Byrx.net分享于2019-03-23 07:03:47
Strings can be subscripted (indexed),subscriptedindexed,#like in C,
#like in C, the first character of a string has subscript (index) 0. #There is no separate character type; a character is simply a string of size one. #Like in Icon, substrings can be specified with the slice notation: #two indices separated by a colon.word = 'Hello world'print word[4]print word[0:2]print word[2:4]print word[:2] # The first two charactersprint word[2:] # Everything except the first two charactersprint 'x' + word[1:]print 'Splat' + word[4]
相关内容
- Bit calculation: shift left,bitcalculation,x = 1
- 1 is true in Python,truepython,if 1: pr
- Loop through a file,loopthroughfile,f=open('/tmp
- Redirecting stdout and stderr Output,redirectingstdout,import sys p
- Capturing clicks in a window,capturingclicks,from Tkinter
- try/except/else,tryexceptelse,# try: nu
- Use system function to output,functionoutput,import sys
- Print out exception info,printexception,#the excepti
- Concatinate two lists,concatinatelists,inventory =
- While with break,whilewithbreak,while 1:
评论关闭