这个应该选什么,为什么语言(-python)啊啊哈哈

img


这个应该选什么,为什么(语言python啊啊哈哈
pytjon

选择 A,因为遇到 j continue跳过了
(严格来说这个程序有个错误,就是== 中间不能分开)

选A,
分析过程: continue 满足条件 i为 J 时,跳过打印的行为,最终只打印了BTU.

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 这有个类似的问题, 你可以参考下: https://ask.csdn.net/questions/7776123
  • 这篇博客也不错, 你可以看下数据运营-计算留存率和转化率(漏斗分析&Python)
  • 除此之外, 这篇博客: 使用Python添加工具箱中的 ③Python访问Python工具箱(.pyt)中的工具 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:

    导入Python工具箱后,能够以arcpy.<工具名称>形式访问自定义工具

    
    >>>arcpy.ImportToolbox(r"D:\制作GP工具\CommonTools.pyt")
    >>>arcpy.Tool(r"D:\制作GP工具\data1706.csv","POINT_X","POINT_Y",r"D:\制作GP工具\scratch.gdb\test")
    

    下述示例介绍如何在Python窗口使用Python工具箱中的工具

    具体实现:

    Python工具箱:

    # -*- coding: utf-8 -*-
    import arcpy
    
    class Toolbox(object):
        def __init__(self):
            """Define the toolbox (the name of the toolbox is the name of the
            .pyt file)."""
            self.label = "Toolbox"
            self.alias = ""
            # List of tool classes associated with this toolbox
            self.tools = [Tool]
    
    class Tool(object):
        def __init__(self):
            """Define the tool (tool name is the name of the class)."""
            self.label = "CSV转点"
            self.description = "CSVToPoint"
            self.canRunInBackground = False
    
        def getParameterInfo(self):
            """Define parameter definitions"""
            in_table = arcpy.Parameter(
                displayName="输入表",
                name="输入表",
                datatype="DEFile",
                parameterType="Required",
                direction="Input")
            in_table.filter.list = ['csv']
    
            x_coords = arcpy.Parameter(
                displayName='x坐标',
                name='x坐标',
                datatype='Field',
                parameterType='Required',
                direction='Input')
            x_coords.parameterDependencies = [in_table.name]
    
            y_coords = arcpy.Parameter(
                displayName='y坐标',
                name='y坐标',
                datatype='Field',
                parameterType='Required',
                direction='Input')
            y_coords.parameterDependencies = [in_table.name]
    
            outFC = arcpy.Parameter(
                displayName='要素类',
                name='要素类',
                datatype='DEFeatureClass',
                parameterType='Required',
                direction='Output')
    
            params = [in_table, x_coords, y_coords, outFC]
            return params
    
        def isLicensed(self):
            return True
    
        def updateParameters(self, parameters):
            return
    
        def updateMessages(self, parameters):
            return
    
        def execute(self, parameters, messages):
            # Get tool parameters
            in_table = parameters[0].valueAsText
            arcpy.AddMessage("输入表 is {0}".format(in_table))
    
            x_coords = parameters[1].valueAsText
            arcpy.AddMessage("x坐标 is {0}".format(x_coords))
    
            y_coords = parameters[2].valueAsText
            arcpy.AddMessage("y坐标 is {0}".format(y_coords))
    
            outFC = parameters[3].valueAsText
            arcpy.AddMessage("要素类 is {0}".format(outFC))
    
            idws = IDW(in_table, x_coords, y_coords, outFC)
            idws.idwByFields()
            return
    
    
    class IDW(object):
        def __init__(self, param1, param2, param3, param4):
            self.param1 = param1  # 第一个参数
            self.param2 = param2  # 第二个参数
            self.param3 = param3  # 第三个参数
            self.param4 = param4  # 第四个参数
    
        def idwByFields(self):
            arcpy.env.overwriteOutput = "true"
    
            # Set the local variables
            in_table = self.param1
            out_feature_class = self.param4
            x_coords = self.param2
            y_coords = self.param3
            z_coords = ""
            # Make the XY event layer...
            arcpy.management.XYTableToPoint(in_table, out_feature_class,
                                            x_coords, y_coords, z_coords,
                                            arcpy.SpatialReference(4326))
    

    Python窗口使用Python工具箱:

    第三方Python编辑器,例如:pycharm,也是可以这样调用Python工具箱中的工具

    import arcpy
    
    # Import custom toolbox
    arcpy.ImportToolbox(r"D:\制作GP工具\CommonTools.pyt")
    
    try:
        # Run tool in the custom toolbox.  The tool is identified by
        #  the tool name and the toolbox alias.
        arcpy.Tool(r"D:\制作GP工具\data1706.csv","POINT_X","POINT_Y",r"D:\制作GP工具\scratch.gdb\test11222")
    except arcpy.ExecuteError:
        print(arcpy.GetMessages(2))

    其中arcpy.Tool中的这个“Tool”是Python工具箱某个工具的名称,对应Python工具箱代码部分的self.tools = [Tool]中的这个“Tool”。

    参考资料:

    https://pro.arcgis.com/zh-cn/pro-app/arcpy/functions/importtoolbox.htm

    https://pro.arcgis.com/zh-cn/pro-app/arcpy/geoprocessing_and_python/adding-and-removing-toolboxes.htm

  • 您还可以看一下 Peter老师的Python数据分析实战与运用-从入门到实战课程中的 Python数据分析实战与运用之数据挖掘篇课程导读小节, 巩固相关知识点

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^