|||
# double or single quotes
>>> 'hey yy'
'hey yy'
>>> "hey yy"
'hey yy'
>>> "he's a handsome man"
"he's a handsome man"
>>> 'he's a handsome man'
"he's a handsome man"
>>> 'he said,"shop!"'
'he said,"shop!"'
>>> "he said,"shop!""
'he said,"shop!"'
>>> a='Jane'
>>> b='Eyre'
>>> a+b # + concatenate strings
'JaneEyre'
>>> a,b
('Jane', 'Eyre')
>>> c='Jane ' # Note the backspace!
>>> c+b
'Jane Eyre'
>>> a='Kamm'
>>> a*5 # * repeat strings
'KammKammKammKammKamm'
>>> b='Tag ' # Note the backspace!
>>> b*3
'Tag Tag Tag '
# convert any format of an element to string using `` and str()
>>> a=18
>>> print 'yy is ' + `a` # The backtick sign `(重音符号) is right below the tilde ~ (波浪符号) on the keyboard.
yy is 18
>>> print 'yy is ' + str(a)
yy is 18
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-2 05:35
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社