问你是否是这样一个变量啊
caesar = "Graham"
praline = "John"
viking = "Teresa"
print caesar
print praline
print viking
变成小写
parrot = "Norwegian Blue"
print parrot.lower()
ministry = "The Ministry of Silly Walks"
print len(ministry)
print ministry.upper()
格式化
name = "Mike"
print "Hello %s" % (name)
name = raw_input("What is your name? ")
quest = raw_input("What is your quest? ")
color = raw_input("What is your favorite color? ")
print "Ah, so your name is %s, your quest is %s, "
"and your favorite color is %s." % (name, quest, color)
可以用%s来替换一段字符串
name = 'Crossin'
print '%s is a good teacher.' % name
输出
Crossin is a good teacher.
或者
print 'Today is %s.' % 'Friday'
输出
Today is Friday.
网友评论