Error[8]: Undefined offset: 5, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

从txt文件中读取坐标并计算相邻两点间的距离并输出txt–Python 本次的编程任务可分解为以下五个部分 1.从txt文件中读取坐标并存入list中
    x, y, z = [], [], []
    with open("C:\Users\Administrator\Desktop\listpoint\274picking_list.txt ", 'r') as A:
        content = A.read()
        contract = content.split()
        length = len(contract)
        print(length)
        for index in range(0, length):
            str1 = contract[index]
            str2 = str1.replace(",", " ")
            str3 = str2.split()
            # print(type(str3[1]))
            x.append(str3[1])
            # print(x)
            y.append(str3[2])
            # print(y)
            z.append(str3[3])
            # print(z)
2.将点按索引分奇偶–使相邻点一一对应
        # 读出的列表值为str型,将str转为int
        px = list(map(float, x))
        py = list(map(float, y))
        pz = list(map(float, z))
        # 将读出的x,y,z分量分奇、偶分别存入两个不同列表
        x_odd = px[0:length:2]
        x_even = px[1:length:2]
        y_odd = py[0:length:2]
        y_even = py[1:length:2]
        z_odd = pz[0:length:2]
        z_even = pz[1:length:2]
3.求相邻两点间的距离
        t = int(length/2)
        dist_final_list = []
        for index in range(0, t):
            dist = (x_even[index]-x_odd[index])**2+(y_even[index]-y_odd[index])**2+(z_even[index]-z_odd[index])**2
            # print(dist)
            dist_final = math.sqrt(dist)
            dist_final_list.append(dist_final)
        # print(dist_final_list)
4.将数据类型转为str型
        # 写入txt的数据类型需为str型,通过map将float转为str
        list_index = []  # 索引
        for index in range(1, t+1):
            list_index.append(index)
        list_index = list(map(str, list_index))
        # print(list_index)
        dist_final_list = list(map(str, dist_final_list))
        x_odd = list(map(str, x_odd))
        y_odd = list(map(str, y_odd))
        z_odd = list(map(str, z_odd))
        x_even = list(map(str, x_even))
        y_even = list(map(str, y_even))
        z_even = list(map(str, z_even))
5.将多个列表对应的值写入txt文件
        with open("C:\Users\Administrator\Desktop\listpoint\274_list1.txt", "a+") as f:
            for i in range(0, t):
                if list_index[i] == '/0' or x_odd[i] == '[+++]' or y_odd[i] == '[+++]' or z_odd[i] == '[+++]' or x_even[i] == '[+++]' or y_even[i] == '[+++]' or z_even[i] == '[+++]':
                    break
                f.write('{:},{:},{:},{:},{:},{:},{:},{:}\n'.format(list_index[i], x_odd[i], y_odd[i], z_odd[i], x_even[i], y_even[i], z_even[i], dist_final_list[i]))
            f.close()
结果

附测试数据(截图版)
注:本次坐标数据来源于火星点云,意在求取火星石块的直径

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 6, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

从txt文件中读取坐标并计算相邻两点间的距离并输出txt–Python 本次的编程任务可分解为以下五个部分 1.从txt文件中读取坐标并存入list中
    x, y, z = [], [], []
    with open("C:\Users\Administrator\Desktop\listpoint\274picking_list.txt ", 'r') as A:
        content = A.read()
        contract = content.split()
        length = len(contract)
        print(length)
        for index in range(0, length):
            str1 = contract[index]
            str2 = str1.replace(",", " ")
            str3 = str2.split()
            # print(type(str3[1]))
            x.append(str3[1])
            # print(x)
            y.append(str3[2])
            # print(y)
            z.append(str3[3])
            # print(z)
2.将点按索引分奇偶–使相邻点一一对应
        # 读出的列表值为str型,将str转为int
        px = list(map(float, x))
        py = list(map(float, y))
        pz = list(map(float, z))
        # 将读出的x,y,z分量分奇、偶分别存入两个不同列表
        x_odd = px[0:length:2]
        x_even = px[1:length:2]
        y_odd = py[0:length:2]
        y_even = py[1:length:2]
        z_odd = pz[0:length:2]
        z_even = pz[1:length:2]
3.求相邻两点间的距离
        t = int(length/2)
        dist_final_list = []
        for index in range(0, t):
            dist = (x_even[index]-x_odd[index])**2+(y_even[index]-y_odd[index])**2+(z_even[index]-z_odd[index])**2
            # print(dist)
            dist_final = math.sqrt(dist)
            dist_final_list.append(dist_final)
        # print(dist_final_list)
4.将数据类型转为str型
        # 写入txt的数据类型需为str型,通过map将float转为str
        list_index = []  # 索引
        for index in range(1, t+1):
            list_index.append(index)
        list_index = list(map(str, list_index))
        # print(list_index)
        dist_final_list = list(map(str, dist_final_list))
        x_odd = list(map(str, x_odd))
        y_odd = list(map(str, y_odd))
        z_odd = list(map(str, z_odd))
        x_even = list(map(str, x_even))
        y_even = list(map(str, y_even))
        z_even = list(map(str, z_even))
5.将多个列表对应的值写入txt文件
        with open("C:\Users\Administrator\Desktop\listpoint\274_list1.txt", "a+") as f:
            for i in range(0, t):
                if list_index[i] == '/0' or x_odd[i] == '' or y_odd[i] == '[+++]' or z_odd[i] == '[+++]' or x_even[i] == '[+++]' or y_even[i] == '[+++]' or z_even[i] == '[+++]':
                    break
                f.write('{:},{:},{:},{:},{:},{:},{:},{:}\n'.format(list_index[i], x_odd[i], y_odd[i], z_odd[i], x_even[i], y_even[i], z_even[i], dist_final_list[i]))
            f.close()
结果

附测试数据(截图版)
注:本次坐标数据来源于火星点云,意在求取火星石块的直径

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 7, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

从txt文件中读取坐标并计算相邻两点间的距离并输出txt–Python 本次的编程任务可分解为以下五个部分 1.从txt文件中读取坐标并存入list中
    x, y, z = [], [], []
    with open("C:\Users\Administrator\Desktop\listpoint\274picking_list.txt ", 'r') as A:
        content = A.read()
        contract = content.split()
        length = len(contract)
        print(length)
        for index in range(0, length):
            str1 = contract[index]
            str2 = str1.replace(",", " ")
            str3 = str2.split()
            # print(type(str3[1]))
            x.append(str3[1])
            # print(x)
            y.append(str3[2])
            # print(y)
            z.append(str3[3])
            # print(z)
2.将点按索引分奇偶–使相邻点一一对应
        # 读出的列表值为str型,将str转为int
        px = list(map(float, x))
        py = list(map(float, y))
        pz = list(map(float, z))
        # 将读出的x,y,z分量分奇、偶分别存入两个不同列表
        x_odd = px[0:length:2]
        x_even = px[1:length:2]
        y_odd = py[0:length:2]
        y_even = py[1:length:2]
        z_odd = pz[0:length:2]
        z_even = pz[1:length:2]
3.求相邻两点间的距离
        t = int(length/2)
        dist_final_list = []
        for index in range(0, t):
            dist = (x_even[index]-x_odd[index])**2+(y_even[index]-y_odd[index])**2+(z_even[index]-z_odd[index])**2
            # print(dist)
            dist_final = math.sqrt(dist)
            dist_final_list.append(dist_final)
        # print(dist_final_list)
4.将数据类型转为str型
        # 写入txt的数据类型需为str型,通过map将float转为str
        list_index = []  # 索引
        for index in range(1, t+1):
            list_index.append(index)
        list_index = list(map(str, list_index))
        # print(list_index)
        dist_final_list = list(map(str, dist_final_list))
        x_odd = list(map(str, x_odd))
        y_odd = list(map(str, y_odd))
        z_odd = list(map(str, z_odd))
        x_even = list(map(str, x_even))
        y_even = list(map(str, y_even))
        z_even = list(map(str, z_even))
5.将多个列表对应的值写入txt文件
        with open("C:\Users\Administrator\Desktop\listpoint\274_list1.txt", "a+") as f:
            for i in range(0, t):
                if list_index[i] == '/0' or x_odd[i] == '' or y_odd[i] == '' or z_odd[i] == '[+++]' or x_even[i] == '[+++]' or y_even[i] == '[+++]' or z_even[i] == '[+++]':
                    break
                f.write('{:},{:},{:},{:},{:},{:},{:},{:}\n'.format(list_index[i], x_odd[i], y_odd[i], z_odd[i], x_even[i], y_even[i], z_even[i], dist_final_list[i]))
            f.close()
结果

附测试数据(截图版)
注:本次坐标数据来源于火星点云,意在求取火星石块的直径

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 8, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

从txt文件中读取坐标并计算相邻两点间的距离并输出txt–Python 本次的编程任务可分解为以下五个部分 1.从txt文件中读取坐标并存入list中
    x, y, z = [], [], []
    with open("C:\Users\Administrator\Desktop\listpoint\274picking_list.txt ", 'r') as A:
        content = A.read()
        contract = content.split()
        length = len(contract)
        print(length)
        for index in range(0, length):
            str1 = contract[index]
            str2 = str1.replace(",", " ")
            str3 = str2.split()
            # print(type(str3[1]))
            x.append(str3[1])
            # print(x)
            y.append(str3[2])
            # print(y)
            z.append(str3[3])
            # print(z)
2.将点按索引分奇偶–使相邻点一一对应
        # 读出的列表值为str型,将str转为int
        px = list(map(float, x))
        py = list(map(float, y))
        pz = list(map(float, z))
        # 将读出的x,y,z分量分奇、偶分别存入两个不同列表
        x_odd = px[0:length:2]
        x_even = px[1:length:2]
        y_odd = py[0:length:2]
        y_even = py[1:length:2]
        z_odd = pz[0:length:2]
        z_even = pz[1:length:2]
3.求相邻两点间的距离
        t = int(length/2)
        dist_final_list = []
        for index in range(0, t):
            dist = (x_even[index]-x_odd[index])**2+(y_even[index]-y_odd[index])**2+(z_even[index]-z_odd[index])**2
            # print(dist)
            dist_final = math.sqrt(dist)
            dist_final_list.append(dist_final)
        # print(dist_final_list)
4.将数据类型转为str型
        # 写入txt的数据类型需为str型,通过map将float转为str
        list_index = []  # 索引
        for index in range(1, t+1):
            list_index.append(index)
        list_index = list(map(str, list_index))
        # print(list_index)
        dist_final_list = list(map(str, dist_final_list))
        x_odd = list(map(str, x_odd))
        y_odd = list(map(str, y_odd))
        z_odd = list(map(str, z_odd))
        x_even = list(map(str, x_even))
        y_even = list(map(str, y_even))
        z_even = list(map(str, z_even))
5.将多个列表对应的值写入txt文件
        with open("C:\Users\Administrator\Desktop\listpoint\274_list1.txt", "a+") as f:
            for i in range(0, t):
                if list_index[i] == '/0' or x_odd[i] == '' or y_odd[i] == '' or z_odd[i] == '' or x_even[i] == '[+++]' or y_even[i] == '[+++]' or z_even[i] == '[+++]':
                    break
                f.write('{:},{:},{:},{:},{:},{:},{:},{:}\n'.format(list_index[i], x_odd[i], y_odd[i], z_odd[i], x_even[i], y_even[i], z_even[i], dist_final_list[i]))
            f.close()
结果

附测试数据(截图版)
注:本次坐标数据来源于火星点云,意在求取火星石块的直径

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 9, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

从txt文件中读取坐标并计算相邻两点间的距离并输出txt–Python 本次的编程任务可分解为以下五个部分 1.从txt文件中读取坐标并存入list中
    x, y, z = [], [], []
    with open("C:\Users\Administrator\Desktop\listpoint\274picking_list.txt ", 'r') as A:
        content = A.read()
        contract = content.split()
        length = len(contract)
        print(length)
        for index in range(0, length):
            str1 = contract[index]
            str2 = str1.replace(",", " ")
            str3 = str2.split()
            # print(type(str3[1]))
            x.append(str3[1])
            # print(x)
            y.append(str3[2])
            # print(y)
            z.append(str3[3])
            # print(z)
2.将点按索引分奇偶–使相邻点一一对应
        # 读出的列表值为str型,将str转为int
        px = list(map(float, x))
        py = list(map(float, y))
        pz = list(map(float, z))
        # 将读出的x,y,z分量分奇、偶分别存入两个不同列表
        x_odd = px[0:length:2]
        x_even = px[1:length:2]
        y_odd = py[0:length:2]
        y_even = py[1:length:2]
        z_odd = pz[0:length:2]
        z_even = pz[1:length:2]
3.求相邻两点间的距离
        t = int(length/2)
        dist_final_list = []
        for index in range(0, t):
            dist = (x_even[index]-x_odd[index])**2+(y_even[index]-y_odd[index])**2+(z_even[index]-z_odd[index])**2
            # print(dist)
            dist_final = math.sqrt(dist)
            dist_final_list.append(dist_final)
        # print(dist_final_list)
4.将数据类型转为str型
        # 写入txt的数据类型需为str型,通过map将float转为str
        list_index = []  # 索引
        for index in range(1, t+1):
            list_index.append(index)
        list_index = list(map(str, list_index))
        # print(list_index)
        dist_final_list = list(map(str, dist_final_list))
        x_odd = list(map(str, x_odd))
        y_odd = list(map(str, y_odd))
        z_odd = list(map(str, z_odd))
        x_even = list(map(str, x_even))
        y_even = list(map(str, y_even))
        z_even = list(map(str, z_even))
5.将多个列表对应的值写入txt文件
        with open("C:\Users\Administrator\Desktop\listpoint\274_list1.txt", "a+") as f:
            for i in range(0, t):
                if list_index[i] == '/0' or x_odd[i] == '' or y_odd[i] == '' or z_odd[i] == '' or x_even[i] == '' or y_even[i] == '[+++]' or z_even[i] == '[+++]':
                    break
                f.write('{:},{:},{:},{:},{:},{:},{:},{:}\n'.format(list_index[i], x_odd[i], y_odd[i], z_odd[i], x_even[i], y_even[i], z_even[i], dist_final_list[i]))
            f.close()
结果

附测试数据(截图版)
注:本次坐标数据来源于火星点云,意在求取火星石块的直径

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 10, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

从txt文件中读取坐标并计算相邻两点间的距离并输出txt–Python 本次的编程任务可分解为以下五个部分 1.从txt文件中读取坐标并存入list中
    x, y, z = [], [], []
    with open("C:\Users\Administrator\Desktop\listpoint\274picking_list.txt ", 'r') as A:
        content = A.read()
        contract = content.split()
        length = len(contract)
        print(length)
        for index in range(0, length):
            str1 = contract[index]
            str2 = str1.replace(",", " ")
            str3 = str2.split()
            # print(type(str3[1]))
            x.append(str3[1])
            # print(x)
            y.append(str3[2])
            # print(y)
            z.append(str3[3])
            # print(z)
2.将点按索引分奇偶–使相邻点一一对应
        # 读出的列表值为str型,将str转为int
        px = list(map(float, x))
        py = list(map(float, y))
        pz = list(map(float, z))
        # 将读出的x,y,z分量分奇、偶分别存入两个不同列表
        x_odd = px[0:length:2]
        x_even = px[1:length:2]
        y_odd = py[0:length:2]
        y_even = py[1:length:2]
        z_odd = pz[0:length:2]
        z_even = pz[1:length:2]
3.求相邻两点间的距离
        t = int(length/2)
        dist_final_list = []
        for index in range(0, t):
            dist = (x_even[index]-x_odd[index])**2+(y_even[index]-y_odd[index])**2+(z_even[index]-z_odd[index])**2
            # print(dist)
            dist_final = math.sqrt(dist)
            dist_final_list.append(dist_final)
        # print(dist_final_list)
4.将数据类型转为str型
        # 写入txt的数据类型需为str型,通过map将float转为str
        list_index = []  # 索引
        for index in range(1, t+1):
            list_index.append(index)
        list_index = list(map(str, list_index))
        # print(list_index)
        dist_final_list = list(map(str, dist_final_list))
        x_odd = list(map(str, x_odd))
        y_odd = list(map(str, y_odd))
        z_odd = list(map(str, z_odd))
        x_even = list(map(str, x_even))
        y_even = list(map(str, y_even))
        z_even = list(map(str, z_even))
5.将多个列表对应的值写入txt文件
        with open("C:\Users\Administrator\Desktop\listpoint\274_list1.txt", "a+") as f:
            for i in range(0, t):
                if list_index[i] == '/0' or x_odd[i] == '' or y_odd[i] == '' or z_odd[i] == '' or x_even[i] == '' or y_even[i] == '' or z_even[i] == '[+++]':
                    break
                f.write('{:},{:},{:},{:},{:},{:},{:},{:}\n'.format(list_index[i], x_odd[i], y_odd[i], z_odd[i], x_even[i], y_even[i], z_even[i], dist_final_list[i]))
            f.close()
结果

附测试数据(截图版)
注:本次坐标数据来源于火星点云,意在求取火星石块的直径

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
从txt文件中读取坐标并计算相邻两点间的距离并输出txt--Python_java_内存溢出

从txt文件中读取坐标并计算相邻两点间的距离并输出txt--Python

从txt文件中读取坐标并计算相邻两点间的距离并输出txt--Python,第1张

从txt文件中读取坐标并计算相邻两点间的距离并输出txt–Python 本次的编程任务可分解为以下五个部分 1.从txt文件中读取坐标并存入list中
    x, y, z = [], [], []
    with open("C:\Users\Administrator\Desktop\listpoint\274picking_list.txt ", 'r') as A:
        content = A.read()
        contract = content.split()
        length = len(contract)
        print(length)
        for index in range(0, length):
            str1 = contract[index]
            str2 = str1.replace(",", " ")
            str3 = str2.split()
            # print(type(str3[1]))
            x.append(str3[1])
            # print(x)
            y.append(str3[2])
            # print(y)
            z.append(str3[3])
            # print(z)
2.将点按索引分奇偶–使相邻点一一对应
        # 读出的列表值为str型,将str转为int
        px = list(map(float, x))
        py = list(map(float, y))
        pz = list(map(float, z))
        # 将读出的x,y,z分量分奇、偶分别存入两个不同列表
        x_odd = px[0:length:2]
        x_even = px[1:length:2]
        y_odd = py[0:length:2]
        y_even = py[1:length:2]
        z_odd = pz[0:length:2]
        z_even = pz[1:length:2]
3.求相邻两点间的距离
        t = int(length/2)
        dist_final_list = []
        for index in range(0, t):
            dist = (x_even[index]-x_odd[index])**2+(y_even[index]-y_odd[index])**2+(z_even[index]-z_odd[index])**2
            # print(dist)
            dist_final = math.sqrt(dist)
            dist_final_list.append(dist_final)
        # print(dist_final_list)
4.将数据类型转为str型
        # 写入txt的数据类型需为str型,通过map将float转为str
        list_index = []  # 索引
        for index in range(1, t+1):
            list_index.append(index)
        list_index = list(map(str, list_index))
        # print(list_index)
        dist_final_list = list(map(str, dist_final_list))
        x_odd = list(map(str, x_odd))
        y_odd = list(map(str, y_odd))
        z_odd = list(map(str, z_odd))
        x_even = list(map(str, x_even))
        y_even = list(map(str, y_even))
        z_even = list(map(str, z_even))
5.将多个列表对应的值写入txt文件
        with open("C:\Users\Administrator\Desktop\listpoint\274_list1.txt", "a+") as f:
            for i in range(0, t):
                if list_index[i] == '/0' or x_odd[i] == '' or y_odd[i] == '' or z_odd[i] == '' or x_even[i] == '' or y_even[i] == '' or z_even[i] == '':
                    break
                f.write('{:},{:},{:},{:},{:},{:},{:},{:}\n'.format(list_index[i], x_odd[i], y_odd[i], z_odd[i], x_even[i], y_even[i], z_even[i], dist_final_list[i]))
            f.close()
结果

附测试数据(截图版)
注:本次坐标数据来源于火星点云,意在求取火星石块的直径

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/790782.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-05
下一篇 2022-05-05

发表评论

登录后才能评论

评论列表(0条)

保存