import arcpy
import sys
import os
import string
reload(sys)
sys.setdefaultencoding("utf8")
scratchWS = arcpy.env.scratchWorkspace
arcpy.AddMessage("默认地理数据库路径:" + scratchWS)
scriptPath = sys.path[0];
arcpy.AddMessage("系统路径:" + scriptPath)
toolSharePath = os.path.dirname(scriptPath)
arcpy.AddMessage("路径:" + toolSharePath)
scratchWS = arcpy.GetSystemEnvironment("TEMP")
arcpy.AddMessage("临时:" + toolSharePath)
arcpy.AddMessage(arcpy.GetMessages())
environments = arcpy.ListEnvironments()
########################################################
#
environments.sort(key=string.lower)
for environment in environments:
# As the environment is passed as a variable, use Python's getattr
# to evaluate the environment's value
#
envSetting = getattr(arcpy.env, environment)
# Format and print each environment and its current setting
#
arcpy.AddMessage( "{0:<30}: {1}".format(environment, envSetting))
结果:
默认地理数据库路径:C:UsersAdministratorDocumentsArcGISDefault.gdb
系统路径:D:
路径:D:
临时:D:
autoCommit : 1000
cartographicCoordinateSystem : None
cellSize : MAXOF
coincidentPoints : MEAN
compression : LZ77
configKeyword : None
derivedPrecision : HIGHEST
extent : None
geographicTransformations : None
maintainSpatialIndex : False
mask : None
MDomain : None
MResolution : None
MTolerance : None
newPrecision : SINGLE
outputCoordinateSystem : None
outputMFlag : Same As Input
outputZFlag : Same As Input
outputZValue : None
projectCompare : NONE
pyramid : PYRAMIDS -1 NEAREST DEFAULT 75
qualifiedFieldNames : True
randomGenerator : 0 ACM599
rasterStatistics : STATISTICS 1 1
referenceScale : None
scratchWorkspace : C:UsersAdministratorDocumentsArcGISDefault.gdb
snapRaster : None
spatialGrid1 : 0.0
spatialGrid2 : 0.0
spatialGrid3 : 0.0
terrainMemoryUsage : False
tileSize : 128 128
tinSaveVersion : CURRENT
workspace : C:UsersAdministratorDocumentsArcGISDefault.gdb
XYDomain : None
XYResolution : None
XYTolerance : None
ZDomain : None
ZResolution : None
ZTolerance : None
Completed script 脚本...
成功 在 Sat Nov 16 08:28:26 2013 (经历的时间: 1.00 秒)
=================================================
#########################
import arcpy
import os
import sys
#################################
#
scriptPath = sys.path[0]
arcpy.AddMessage("Script folder: " + scriptPath)
toolSharePath = os.path.dirname(scriptPath)
num=len(sys.path)
for i in range(num):
scriptPath = sys.path[i]
arcpy.AddMessage("Script folder: " + scriptPath+":"+str(i))
结果如下:
消息
执行: 导入工具箱 #
开始时间: Fri Jul 19 13:49:41 2019
正在运行脚本 导入工具箱...
Script folder: F: knew106 ool
ToolShare folder: F: knew106
Script folder: C:WINDOWSSYSTEM32python26.zip
Script folder: C:Program Files (x86)ArcGISDesktop10.0arcpy
Script folder: C:Python26ArcGIS10.0Lib
Script folder: C:Python26ArcGIS10.0DLLs
Script folder: C:Python26ArcGIS10.0Liblib-tk
Script folder: C:Program Files (x86)ArcGISDesktop10.0Bin
Script folder: F: knew106 ool:0
Script folder: C:WINDOWSSYSTEM32python26.zip:1
Script folder: C:Program Files (x86)ArcGISDesktop10.0arcpy:2
Script folder: C:Python26ArcGIS10.0Lib:3
Script folder: C:Python26ArcGIS10.0DLLs:4
Script folder: C:Python26ArcGIS10.0Liblib-tk:5
Script folder: C:Program Files (x86)ArcGISDesktop10.0Bin:6
Script folder: C:Python26ArcGIS10.0:7
Script folder: C:Python26ArcGIS10.0libsite-packages:8
Script folder: C:Program Files (x86)ArcGISDesktop10.0arcpy:9
Script folder: C:Program Files (x86)ArcGISDesktop10.0ArcToolboxScripts:10
Script folder: C:Python26ArcGIS10.0libsite-packageswin32:11
Script folder: C:Python26ArcGIS10.0libsite-packageswin32lib:12
Script folder: C:Python26ArcGIS10.0libsite-packagesPythonwin:13
Completed script 导入工具箱...
成功 在 Fri Jul 19 13:49:41 2019 (经历的时间: 0.00 秒)