发布网友 发布时间:2022-04-22 06:09
共1个回答
热心网友 时间:2022-04-07 12:36
摘要"#!/usr/bin/python\# -*- coding: UTF-8 -*-\\from tkinter import *\import tkinter.filedialog\\root = Tk()\root.title('去除文件重复行')\root.geometry('300x200')\FileName1 = \"\"\FileName2 = \"\"\\def Button1Anwser():\ global FileName1\ Path = Label(root, text='')\ FileName1 = tkinter.filedialog.askopenfilename()\ Path.config(text=FileName1)\ Path.grid(row=1, column=0, sticky=W)\\def Button2Anwser():\ global FileName2\ Path = Label(root, text='')\ FileName2 = tkinter.filedialog.askopenfilename()\ Path.config(text=FileName2)\ Path.grid(row=3, column=0, sticky=W)\\def Start():\ fp = open(FileName1, 'r+')\ fp0 = open(FileName2, 'w')\ Read = fp.read()\ Content = Read.split('\\n')\ New_Content = []\\ Text = Label(root, text='')\ Text.config(text='正在处理')\ Text.grid(row=4, column=1)\\ for i in range(len(Content)):\ if Content[i] not in New_Content:\ New_Content.append(Content[i])\ for i in range(len(New_Content)):\ fp0.write"咨询记录 · 回答于2021-06-08Python怎么删除重复的行。"#!/usr/bin/python\# -*- coding: UTF-8 -*-\\from tkinter import *\import tkinter.filedialog\\root = Tk()\root.title('去除文件重复行')\root.geometry('300x200')\FileName1 = \"\"\FileName2 = \"\"\\def Button1Anwser():\ global FileName1\ Path = Label(root, text='')\ FileName1 = tkinter.filedialog.askopenfilename()\ Path.config(text=FileName1)\ Path.grid(row=1, column=0, sticky=W)\\def Button2Anwser():\ global FileName2\ Path = Label(root, text='')\ FileName2 = tkinter.filedialog.askopenfilename()\ Path.config(text=FileName2)\ Path.grid(row=3, column=0, sticky=W)\\def Start():\ fp = open(FileName1, 'r+')\ fp0 = open(FileName2, 'w')\ Read = fp.read()\ Content = Read.split('\\n')\ New_Content = []\\ Text = Label(root, text='')\ Text.config(text='正在处理')\ Text.grid(row=4, column=1)\\ for i in range(len(Content)):\ if Content[i] not in New_Content:\ New_Content.append(Content[i])\ for i in range(len(New_Content)):\ fp0.write"你好,能不能给个思路和注释"df:目标数据框\drop_plicates:删除重复值函数\keep=\"first\":保留第一个样本(记录)\inplace=True:新数据结果替换掉原来的数据"