Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Don';我不想在python代码中使用单引号_Python_Python 2.7_Python 2.x - Fatal编程技术网

Don';我不想在python代码中使用单引号

Don';我不想在python代码中使用单引号,python,python-2.7,python-2.x,Python,Python 2.7,Python 2.x,我正在使用Python 2.7。。。我面临的问题是当我使用此代码时 print "How old are you?", age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weigh?", weight = raw_input() print "So, you're %r old, %r tall and %r heavy." % (

我正在使用Python 2.7。。。我面临的问题是当我使用此代码时

print "How old are you?",   
age = raw_input()  
print "How tall are you?",  
height = raw_input()  
print "How much do you weigh?",  
weight = raw_input()  

print "So, you're %r old, %r tall and %r heavy." % (
    age, height, weight)
结果是-

How old are you? 35  
How tall are you? 6'2"  
How much do you weigh? 180lbs  
So, you're '35' old, '6\'2"' tall and '180lbs' heavy.

但我不希望输出的第四行中出现35180磅和6.2英寸左右的单引号。如何做不要使用
%r
。更改:

print "So, you're %r old, %r tall and %r heavy." % ( age, height, weight)
致:

repr()

以下是解释器中的一个示例:

>>> print '%r' % 'Hi' 'Hi' >>> print '%s' % 'Hi' Hi >>> >>>打印“%r%”嗨 “嗨” >>>打印“%s”%”嗨 你好 >>>
看看学生们常见的问题:Zed通常会回答这样的问题,他当然会回答这样的问题。 >>> print '%r' % 'Hi' 'Hi' >>> print '%s' % 'Hi' Hi >>>