import openpyxl #写 # book = openpyxl.Workbook() # sheet = book.active #默认的sheet # #sheet2 = book.get_sheet_by_name('sheet1') # # sheet.append( ['id','username','password','error_count']) # # sheet.append( [1,'wyj','123456',0]) # # sheet.append( [2,'wyj','123456']) # sheet['a1'] = 'id' #指定行列 # sheet['b1'] = 'username'# # sheet.cell(3,1,'1')#指定行和列 # book.save('user.xlsx') book = openpyxl.load_workbook('user.xlsx') Sheet = book.active # Print (sheet.cell (1,1) .Value) # Print (Sheet [ 'A1']. value) # data print (list (sheet.rows)) # all the lines # L = [ ] # Print (List (sheet.columns)) # All columns # for row in sheet.rows: # t = [] # for col in row: # t.append(col.value) # l.append(t) # print(l) # Print (Sheet [1:10]) # few lines to the first few lines sheet.cell (0,0, ' sdfsd ' ) sheet.delete_cols ( . 1) # delete column sheet.delete_rows (. 1) # function line book.save ( ' user.xlsx ' )