01/10/2018, 10:06

% trong python trong code

mình mới học cho mình hỏi ở đoạn này:
1.hilarious = False
2.joke_evaluation = “Isn’t that joke so funny?! %r”
3.
4.print joke_evaluation % hilarious
Trong đoạn này % giữa joke_evaluation, hilarious dòng thứ 4 và %r ở dòng thứ 2 làm gì ?
Ai trả lời dùm mình. Cảm ơn!

Henry viết 12:12 ngày 01/10/2018

Nó cũng tương đương bạn làm như thế này

>>> hilarious = False
>>> print("Isn't that joke so funny?! %r" %hilarious)
Isn't that joke so funny?! False

Bạn vẫn còn khá mông lung?

>>> print("Isn't that joke so funny?! %r" %False)
Isn't that joke so funny?! False

>>> name = "An"
>>> hello = "My name is %s"
>>> print(hello %name)
My name is An

Cũng tương tự như

>>> name = "An"
>>> print("My name is %s" %name)
My name is An
An Thúy viết 12:13 ngày 01/10/2018

cảm ơn bạn

Bài liên quan
0