>> 'n' 'n' >...">

I am confused by the difference between "n" and print ("n")

I am still confused when entering this command in the Python shell:

>>> 'n'
'n'
>>> print('n')
n

What does 'n'(first conclusion) mean ? And what does the second mean n? Why doesn't Python just print nas output 'n'is the same as print('n')?

I think that print('n')means: I (Python) print nas a character

Then what about the first? if it >>> 'n'means the same, why doesn't it just print n?

+4
source share
4 answers

python , . , , None, :

print(repr(result))

'n', .

print(), , ( str(), , ).

Python script; , 'n' , Python , . print('n'), , .

, python, repr(), . 1 "1", 1 :

>>> print(1)
1
>>> print("1")
1

. :

>>> 1
1
>>> "1"
'1'

Python , Python, .

+5

(). print n, .

0

.py , print('n') -, 'n' .

, , None, . , 'n' 'n' . , , , .

0

, python - OBJECT. "n" - , print "n". (OBJECT.__str__()).

class Human:
    def __init__(self,name,ge,age):
         self.ge = ge
         self.age = age
         self.name = name
    def __str__(self):
         print "This is",self.name
         print "age = ",self.age
         print "gender = ".self.ge

boy = Human("Tom", "M", 12)
print boy
0

All Articles