Difference between __file__ and sys.argv[0]

后端 未结 4 539
面向向阳花
面向向阳花 2020-12-10 23:39

Is there any difference between:

__file__

and

sys.argv[0]

Because both seem to be doing the same thing: they hold

4条回答
  •  暖寄归人
    2020-12-11 00:41

    Actually argv[0] might be a script name or a full path to the script + script name, depending on the os.

    Here's the entry in official documentation http://docs.python.org/py3k/library/sys.html#sys.argv

提交回复
热议问题