通过阅读“了解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
,并产生输出:
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.'.
为了看到使用%s和%R在上线之间的区别,我取代了它
,现在获得的输出:
I said: 'There are 10 types of people.'.
I also said: "Those who know binary and those who don't.".
我的问题是:为什么现在有双引号而不是单引号?
很好地解释和展示 –
谢谢,清楚和直接的答案。现在我发现作者在书中提出了同样的观点。 – agtortorella