打印字符串,字符串单双引号均可
print "This is fun."
print 'Yay! Printing.'
注释符号 #
# A comment, this is so you can read your program later.
# Anything after the # is ignored by python.
格式化打印
my_name = 'Zed A. Shaw'
my_height = 74 # inches
my_eyes = 'Blue'
my_hair = 'Brown'
print "Let's talk about %s." % my_name
print "He's %d inches tall." % my_height
print "He's got %s eyes and %s hair." % (my_eyes, my_hair)%r 不管什么都打印出来
本文介绍了Python中打印字符串的基本方法,包括使用单引号和双引号的简单打印,以及使用注释来提高代码可读性。此外,还展示了如何通过格式化字符串来实现更复杂的打印效果。
443

被折叠的 条评论
为什么被折叠?



