通过python查找第31行从第2列到14列的数字,如果数字为0,则删除掉。

方法1:直接赋值为空值

import numpy as np
def del_0():
   for i in range(2,14):
      cell_value =sheet1.cell(row=31, column=i).value
      if cell_value == 0:
         sheet1.cell(31, i).value=" "

方法:直接赋值为None

import numpy as np
def del_0():
   for i in range(2,14):
      cell_value =sheet1.cell(row=31, column=i).value
      if cell_value == 0:
         sheet1.cell(31, i).value=None

方法3:导入numpy,赋值为np.nan

import numpy as np
def del_0():
   for i in range(2,14):
      cell_value =sheet1.cell(row=31, column=i).value
      if cell_value == 0:
         sheet1.cell(31, i).value=np.nan