문제

Edit:
The accompanying code had a few bugs that were otherwise unrelated to the question as titled. The answer is simple enough, so I'm eliminating the irrelevant code so that the question, as asked in the title, and answer are more clearly intelligible to those searching for such things. Thanks to everyone who took the time to read the code and give me some feedback!

Original question, abridged: I seem to be having trouble when my Python script tries to access the dict entry '"__main__":', which is keyed by '__name__ =='. Is my problem related to use of these strings as variables, or is it more likely that my script is failing elsewhere? (SPOILER: My algorithm was wrong.)

도움이 되었습니까?

해결책

Both '__name__' and '==' can serve as the key of dictionary:

>>> d = {'__name__':1, '==':2}
>>> d['__name__']
1
>>> d['==']
2
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top