Cách so sánh trong python

‘a’==1
false
name==‘main
true
là sao em không hiểu, cần lời giải thích

type(‘a’) là string
type(1) là int
===> FALSE

Còn cái name==‘main’ ==> FALSE luôn mà.
Test sao ra True vậy bác :frowning:

__name__=='__main__'

=>true
đã test

1 Like

Sao ở trên ghi: name==‘main’ :frowning:

Bác đọc bên này đi bác.

'__name__' là tên file rùi :frowning:

'__main__' is the name of the scope in which top-level code executes.
A module’s __name__is set equal to '__main__'when read from
standard input, a script, or from an interactive prompt.

https://docs.python.org/3/library/main.html

Đọc cái này nữa là xong vấn đề rùi nè bác
http://effbot.org/pyfaq/tutor-what-is-if-name-main-for.htm

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?