为什么IronPython sys.path与常规Python不一致?

时间:2015-08-20 15:46:31

标签: python python-2.7 python-3.x ironpython

根据https://docs.python.org/2/library/sys.html#sys.path,sys.path中的第一项应该是解释器最初调用的脚本目录。

我创建了一个简单的脚本,打印出sys.path和sys.argv中包含的信息并获得以下内容(请注意,运行的两个脚本之间的区别仅在于/ Python一个()用于打印和/ IronPython一个不会:

System Info: 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] Copyright (c) 2001-2015 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.

Hello world!

Sys.Path:
 - c:\Users\220040509\workspace\ApplianceTools\Source\Scripts\Python
 - C:\Windows\system32\python34.zip
 - C:\Python34\DLLs
 - C:\Python34\lib
 - C:\Python34
 - C:\Python34\lib\site-packages

Sys.Argv:
 - <class 'str'> : Python/sysTest.py
System Info: 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] Copyright (c) 2001-2013 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.

Hello world!

Sys.Path:
 - c:\Users\220040509\workspace\ApplianceTools\Source\Scripts\IronPython
 - C:\Windows\system32\python27.zip
 - c:\Python27\DLLs
 - c:\Python27\lib
 - c:\Python27\lib\plat-win
 - c:\Python27\lib\lib-tk
 - c:\Python27
 - c:\Python27\lib\site-packages

Sys.Argv:
 - <type 'str'> : IronPython/sysTest.py
System Info: 2.7.5 (IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.18063 (32-bit)) Copyright (c) IronPython Team

Hello world!

Sys.Path:
 - IronPython/sysTest.py
 - c:\Users\220040509\workspace\ApplianceTools\Source\Scripts\IronPython
 - c:\Program Files (x86)\IronPython 2.7\Lib
 - c:\Program Files (x86)\IronPython 2.7\DLLs
 - c:\Program Files (x86)\IronPython 2.7
 - c:\Program Files (x86)\IronPython 2.7\lib\site-packages

Sys.Argv:
 - <type 'str'> : IronPython/sysTest.py

为什么IronPython将脚本文件(也是sys.argv [0])作为sys.path [0]?

(在Git Bash中运行,因此混合了\和/)

0 个答案:

没有答案