-
String short version & TemplatePython 2014. 5. 10. 23:43
website = 'www.python.com'
print (website)
print (website[4:])
print (website[-3])
print (website[-3:])
website = 'www.%s.%s'
value = ('yahoo','com')
print (website % value)
format = 'pi with 3 decimal points %.3f'
from math import pi
print (format % pi)
from string import Template
s = Template('$x, glorois $x')
print(s.safe_substitute(x='Kiss'))
a = Template('A $thing must be never $action.')
d={}
d['thing']= 'gentleman'
d['action']= 'shows his shock'
print(a.safe_substitute(d))
'Python' 카테고리의 다른 글
String Formatting (0) 2014.05.11 Tuple (0) 2014.05.09 List & List member function (0) 2014.05.09 Slicing (0) 2014.05.07 연속된 문자열 처리 (0) 2014.05.07