通过阅读“艰苦学习Python”,我尝试了修改练习6,以了解会发生什么。最初它包含:
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." % (binary, do_not)
print "I said: %r." % x
print "I also said: '%s'." % y
并产生输出:
I said: 'There are 10 types of people.'.
I also said: 'Those who know binary and those who don't.'.
为了查看在最后一行中使用%s和%r之间的区别,我将其替换为:
print "I also said: %r." % y
并现在获得输出:
I said: 'There are 10 types of people.'.
I also said: "Those who know binary and those who don't.".
我的问题是: 为什么现在有双引号而不是单引号?
摇曳的蔷薇
海绵宝宝撒
相关分类