Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用csv删除excel文件中的行_Python_Python 3.x_Csv_Tkinter - Fatal编程技术网

Python 如何使用csv删除excel文件中的行

Python 如何使用csv删除excel文件中的行,python,python-3.x,csv,tkinter,Python,Python 3.x,Csv,Tkinter,很抱歉将整个线程拖了一千年,使其无法解决,但我已经解决了大多数问题,只是我想修复我的删除代码,但我不知道从哪里开始 def delete_record(): with open('StudentDetails.csv', 'wb',) as csvfile: csvFileWriter = csv.writer(csvfile) a = delete_student_entry.get() b = delete_password_en

很抱歉将整个线程拖了一千年,使其无法解决,但我已经解决了大多数问题,只是我想修复我的删除代码,但我不知道从哪里开始

def delete_record():
    with open('StudentDetails.csv', 'wb',) as csvfile:
         csvFileWriter = csv.writer(csvfile)
         a = delete_student_entry.get()
         b = delete_password_entry.get()
         csvFileWriter.writerow([a,b])

我希望程序从窗口的输入框中获取输入(因为我正在使用Tkinter),并从输入中删除整行。我欢迎对代码进行任何重写,因为它将是我的“删除学生”菜单的子例程(我知道,非常规,但使用其他形式的调用子例程将导致错误,我别无选择,只能这样做…)

您的意思是从CSV文件中删除从条目中获得的行吗? 如果是这样,您的答案可以在这里找到:

您好,我尝试过在帖子中使用答案,但我认为这不是我要找的。我试图利用csv库,但我只知道如何添加新行,而不是删除它们。。。