FishC
发表于 2024-3-20 09:22:01
凊风 发表于 2024-03-20 09:21
回复请注意python格式
非常抱歉,以下是修正后的代码并遵循了Python的语法格式:
import openpyxl
import xlrd
from tkinter import Tk, filedialog
def open_workbook(file_path):
if file_path.endswith('.xls'):
return xlrd.open_workbook(file_path)
elif file_path.endswith('.xlsx'):
return openpyxl.load_workbook(file_path)
else:
raise ValueError('Invalid file format')
def get_sheet_names(workbook):
if isinstance(workbook, xlrd.Book):
return workbook.sheet_names()
elif isinstance(workbook, openpyxl.Workbook):
return workbook.sheetnames
else:
raise ValueError('Invalid workbook type')
def get_column_names(sheet):
if isinstance(sheet, xlrd.Sheet):
return sheet.row_values(0)
elif isinstance(sheet, openpyxl.worksheet.worksheet.Worksheet):
return
else:
raise ValueError('Invalid sheet type')
def convert_cell_format(cell_value, cell_format):
if cell_format == '文本':
if isinstance(cell_value, (int, float)):
return str(cell_value)
else:
return cell_value
elif cell_format == '日期':
if isinstance(cell_value, str):
return datetime.datetime.strptime(cell_value, '%Y-%m-%d').date()
else:
return cell_value
elif cell_format == '数值':
if isinstance(cell_value, (str, datetime.date)):
return float(cell_value)
else:
return cell_value
def main():
root = Tk()
root.withdraw()
file_path = filedialog.askopenfilename(title='选择工作簿', filetypes=(('Excel files', '*.xlsx'),))
root.destroy()
workbook = open_workbook(file_path)
while True:
sheet_names = get_sheet_names(workbook)
print('请选择要操作的sheet:')
for i, name in enumerate(sheet_names):
print(f'{i+1}. {name}')
sheet_index = int(input('请输入选项序号:')) - 1
sheet_name = sheet_names
sheet = workbook
column_names = get_column_names(sheet)
print('请选择要转换格式的列:')
for i, name in enumerate(column_names):
print(f'{i+1}. {name}')
column_index = int(input('请输入选项序号:')) - 1
column_name = column_names
cell_formats = ['文本', '日期', '数值']
print('请选择转换后的单元格格式:')
for i, format in enumerate(cell_formats):
print(f'{i+1}. {format}')
cell_format_index = int(input('请输入选项序号:')) - 1
cell_format = cell_formats
column_number = column_index + 1
sheet.insert_cols(column_number + 1)
for row_index, row_values in enumerate(sheet.iter_rows(min_row=2, values_only=True), start=2):
cell_value = row_values
converted_value = convert_cell_format(cell_value, cell_format)
sheet.cell(row=row_index, column=column_number + 1, value=converted_value)
workbook.save(file_path)
print('转换完成!')
choice = input('是否继续转换?(是/否)')
if choice.lower() != '是':
break
if __name__ == '__main__':
main()
非常抱歉给您带来的不便,请使用这段修正后的代码,并尝试运行。如果还有其他问题,请随时提问。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:23:11
FishC 发表于 2024-3-20 09:22
非常抱歉,以下是修正后的代码并遵循了Python的语法格式:
报错:
Traceback (most recent call last):
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 101, in <module>
main()
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 68, in main
column_names = get_column_names(sheet)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 25, in get_column_names
if isinstance(sheet, xlrd.Sheet):
^^^^^^^^^^
AttributeError: module 'xlrd' has no attribute 'Sheet'. Did you mean: 'sheet'?
FishC
发表于 2024-3-20 09:23:33
凊风 发表于 2024-03-20 09:23
报错:
Traceback (most recent call last):
File ...
非常抱歉给您带来困扰。根据错误提示,是因为`xlrd`库中没有`Sheet`属性。我修改了代码以解决这个问题,请尝试以下代码:
import openpyxl
import xlrd
from tkinter import Tk, filedialog
def open_workbook(file_path):
if file_path.endswith('.xls'):
return xlrd.open_workbook(file_path)
elif file_path.endswith('.xlsx'):
return openpyxl.load_workbook(file_path)
else:
raise ValueError('Invalid file format')
def get_sheet_names(workbook):
if isinstance(workbook, xlrd.Book):
return workbook.sheet_names()
elif isinstance(workbook, openpyxl.Workbook):
return workbook.sheetnames
else:
raise ValueError('Invalid workbook type')
def get_column_names(sheet):
if isinstance(sheet, xlrd.sheet.Sheet):
return sheet.row_values(0)
elif isinstance(sheet, openpyxl.worksheet.worksheet.Worksheet):
return
else:
raise ValueError('Invalid sheet type')
def convert_cell_format(cell_value, cell_format):
if cell_format == '文本':
if isinstance(cell_value, (int, float)):
return str(cell_value)
else:
return cell_value
elif cell_format == '日期':
if isinstance(cell_value, str):
return datetime.datetime.strptime(cell_value, '%Y-%m-%d').date()
else:
return cell_value
elif cell_format == '数值':
if isinstance(cell_value, (str, datetime.date)):
return float(cell_value)
else:
return cell_value
def main():
root = Tk()
root.withdraw()
file_path = filedialog.askopenfilename(title='选择工作簿', filetypes=(('Excel files', '*.xlsx'),))
root.destroy()
workbook = open_workbook(file_path)
while True:
sheet_names = get_sheet_names(workbook)
print('请选择要操作的sheet:')
for i, name in enumerate(sheet_names):
print(f'{i+1}. {name}')
sheet_index = int(input('请输入选项序号:')) - 1
sheet_name = sheet_names
sheet = workbook
column_names = get_column_names(sheet)
print('请选择要转换格式的列:')
for i, name in enumerate(column_names):
print(f'{i+1}. {name}')
column_index = int(input('请输入选项序号:')) - 1
column_name = column_names
cell_formats = ['文本', '日期', '数值']
print('请选择转换后的单元格格式:')
for i, format in enumerate(cell_formats):
print(f'{i+1}. {format}')
cell_format_index = int(input('请输入选项序号:')) - 1
cell_format = cell_formats
column_number = column_index + 1
sheet.insert_cols(column_number + 1)
for row_index, row_values in enumerate(sheet.iter_rows(min_row=2, values_only=True), start=2):
cell_value = row_values
converted_value = convert_cell_format(cell_value, cell_format)
sheet.cell(row=row_index, column=column_number + 1, value=converted_value)
workbook.save(file_path)
print('转换完成!')
choice = input('是否继续转换?(是/否)')
if choice.lower() != '是':
break
if __name__ == '__main__':
main()
请再次尝试运行,希望这次能够成功。如果还有其他问题,请随时提问。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:31:48
FishC 发表于 2024-3-20 09:23
非常抱歉给您带来困扰。根据错误提示,是因为`xlrd`库中没有`Sheet`属性。我修改了代码以解决这个问题 ...
请选择要操作的sheet:
1. Sheet1
请输入选项序号:1
Traceback (most recent call last):
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 101, in <module>
main()
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 68, in main
column_names = get_column_names(sheet)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 25, in get_column_names
if isinstance(sheet, xlrd.Sheet):
^^^^^^^^^^
AttributeError: module 'xlrd' has no attribute 'Sheet'. Did you mean: 'sheet'?
FishC
发表于 2024-3-20 09:32:11
凊风 发表于 2024-03-20 09:31
请选择要操作的sheet:
1. Sheet1
请输入选项序号: ...
非常抱歉,我之前的回答中仍然存在错误。根据最新的错误提示,'xlrd'库确实没有`Sheet`属性。我已经修改了代码以解决这个问题,请尝试以下代码:import openpyxlimport xlrdfrom tkinter import Tk, filedialogdef open_workbook(file_path): if file_path.endswith('.xls'): return xlrd.open_workbook(file_path) elif file_path.endswith('.xlsx'): return openpyxl.load_workbook(file_path) else: raise ValueError('Invalid file format')def get_sheet_names(workbook): if isinstance(workbook, xlrd.Book): return workbook.sheet_names() elif isinstance(workbook, openpyxl.Workbook): return workbook.sheetnames else: raise ValueError('Invalid workbook type')def get_column_names(sheet): if isinstance(sheet, xlrd.sheet.Sheet): return sheet.row_values(0) elif isinstance(sheet, openpyxl.worksheet.worksheet.Worksheet): return .value for col in sheet.iter_cols(min_row=1, max_row=1)] else: raise ValueError('Invalid sheet type')def convert_cell_format(cell_value, cell_format): if cell_format == '文本': if isinstance(cell_value, (int, float)): return str(cell_value) else: return cell_value elif cell_format == '日期': if isinstance(cell_value, str): return datetime.datetime.strptime(cell_value, '%Y-%m-%d').date() else: return cell_value elif cell_format == '数值': if isinstance(cell_value, (str, datetime.date)): return float(cell_value) else: return cell_valuedef main(): root = Tk() root.withdraw() file_path = filedialog.askopenfilename(title='选择工作簿', filetypes=(('Excel files', '*.xlsx'),)) root.destroy() workbook = open_workbook(file_path) while True: sheet_names = get_sheet_names(workbook) print('请选择要操作的sheet:') for i, name in enumerate(sheet_names): print(f'{i+1}. {name}') sheet_index = int(input('请输入选项序号:')) - 1 sheet_name = sheet_names sheet = workbook column_names = get_column_names(sheet) print('请选择要转换格式的列:') for i, name in enumerate(column_names): print(f'{i+1}. {name}') column_index = int(input('请输入选项序号:')) - 1 column_name = column_names cell_formats = print('请选择转换后的单元格格式:') for i, format in enumerate(cell_formats): print(f'{i+1}. {format}') cell_format_index = int(input('请输入选项序号:')) - 1 cell_format = cell_formats sheet.insert_cols(column_index + 2) for row_index, row in enumerate(sheet.iter_rows(min_row=2), start=2): cell_value = row.value converted_value = convert_cell_format(cell_value, cell_format) sheet.cell(row=row_index, column=column_index + 2, value=converted_value) workbook.save(file_path) print('转换完成!') choice = input('是否继续转换?(是/否)') if choice.lower() != '是': breakif __name__ == '__main__': main()请再次尝试运行,希望这次能够成功。如果还有其他问题,请随时提问。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:32:59
FishC 发表于 2024-3-20 09:32
非常抱歉,我之前的回答中仍然存在错误。根据最新的错误提示,'xlrd'库确实没有`Sheet`属性。我已经修 ...
回复请注意python格式
FishC
发表于 2024-3-20 09:33:14
凊风 发表于 2024-03-20 09:32
回复请注意python格式
非常抱歉,下面是修改后的代码,格式已经修正:
import openpyxl
import xlrd
from tkinter import Tk, filedialog
def open_workbook(file_path):
if file_path.endswith('.xls'):
return xlrd.open_workbook(file_path)
elif file_path.endswith('.xlsx'):
return openpyxl.load_workbook(file_path)
else:
raise ValueError('Invalid file format')
def get_sheet_names(workbook):
if isinstance(workbook, xlrd.Book):
return workbook.sheet_names()
elif isinstance(workbook, openpyxl.Workbook):
return workbook.sheetnames
else:
raise ValueError('Invalid workbook type')
def get_column_names(sheet):
if isinstance(sheet, xlrd.sheet.Sheet):
return sheet.row_values(0)
elif isinstance(sheet, openpyxl.worksheet.worksheet.Worksheet):
return
else:
raise ValueError('Invalid sheet type')
def convert_cell_format(cell_value, cell_format):
if cell_format == '文本':
if isinstance(cell_value, (int, float)):
return str(cell_value)
else:
return cell_value
elif cell_format == '日期':
if isinstance(cell_value, str):
return datetime.datetime.strptime(cell_value, '%Y-%m-%d').date()
else:
return cell_value
elif cell_format == '数值':
if isinstance(cell_value, (str, datetime.date)):
return float(cell_value)
else:
return cell_value
def main():
root = Tk()
root.withdraw()
file_path = filedialog.askopenfilename(title='选择工作簿', filetypes=(('Excel files', '*.xlsx'),))
root.destroy()
workbook = open_workbook(file_path)
while True:
sheet_names = get_sheet_names(workbook)
print('请选择要操作的sheet:')
for i, name in enumerate(sheet_names):
print(f'{i+1}. {name}')
sheet_index = int(input('请输入选项序号:')) - 1
sheet_name = sheet_names
sheet = workbook
column_names = get_column_names(sheet)
print('请选择要转换格式的列:')
for i, name in enumerate(column_names):
print(f'{i+1}. {name}')
column_index = int(input('请输入选项序号:')) - 1
column_name = column_names
cell_formats = ['文本', '日期', '数值']
print('请选择转换后的单元格格式:')
for i, format in enumerate(cell_formats):
print(f'{i+1}. {format}')
cell_format_index = int(input('请输入选项序号:')) - 1
cell_format = cell_formats
sheet.insert_cols(column_index + 2)
for row_index, row in enumerate(sheet.iter_rows(min_row=2), start=2):
cell_value = row.value
converted_value = convert_cell_format(cell_value, cell_format)
sheet.cell(row=row_index, column=column_index + 2, value=converted_value)
workbook.save(file_path)
print('转换完成!')
choice = input('是否继续转换?(是/否)')
if choice.lower() != '是':
break
if __name__ == '__main__':
main()
非常抱歉给您带来困惑,请尝试运行这段代码,希望能解决问题。如还有其他问题,请随时提问。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:36:20
FishC 发表于 2024-3-20 09:33
非常抱歉,下面是修改后的代码,格式已经修正:
请选择要操作的sheet:
1. Sheet1
请输入选项序号:1
Traceback (most recent call last):
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 96, in <module>
main()
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 67, in main
column_names = get_column_names(sheet)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 28, in get_column_names
return
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 28, in <listcomp>
return
^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'value'
FishC
发表于 2024-3-20 09:36:34
凊风 发表于 2024-03-20 09:36
请选择要操作的sheet:
1. Sheet1
请输入选项序号: ...
非常抱歉,我在代码中有一个错误。请将以下行的`column_names`的赋值语句更正为:
column_names =
这样可以确保在`get_column_names`函数中正确获取所有列名。非常抱歉给您带来困扰,请尝试修改后再次运行代码。如还有其他问题,请随时提问。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:37:52
FishC 发表于 2024-3-20 09:36
非常抱歉,我在代码中有一个错误。请将以下行的`column_names`的赋值语句更正为:
这样可以确保在`g ...
在哪里改?
FishC
发表于 2024-3-20 09:37:59
凊风 发表于 2024-03-20 09:37
在哪里改?
非常抱歉,我之前的回答有误导性。在代码中,您需要更正以下两行:
将:
sheet = workbook
更正为:
sheet = workbook]
将:
column_name = column_names
更正为:
column_name = column_names
这样可以确保正确获取用户选择的sheet和列。再次对之前的错误回答表示歉意,并感谢您的指正。如还有其他问题,请随时提问。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:41:13
FishC 发表于 2024-3-20 09:37
非常抱歉,我之前的回答有误导性。在代码中,您需要更正以下两行:
将:
请选择要操作的sheet:
1. Sheet1
请输入选项序号:1
Traceback (most recent call last):
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 97, in <module>
main()
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 68, in main
column_names = get_column_names(sheet)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 28, in get_column_names
return
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 28, in <listcomp>
return
^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'value'
FishC
发表于 2024-3-20 09:41:21
凊风 发表于 2024-03-20 09:41
请选择要操作的sheet:
1. Sheet1
请输入选项序号: ...
非常抱歉给您带来困惑。在代码中,我犯了一个错误。
原因在于,当您通过`workbook`获取要操作的sheet时,返回的是一个元组(tuple),而不是一个具体的sheet对象。
为了解决这个问题,需要将以下代码:
sheet = workbook
更改为:
sheet_name = sheet_names
sheet = workbook
这样就可以正确获取用户选择的sheet对象了。
对于`get_column_names`函数中的`if isinstance(sheet, xlrd.Sheet)`分支,也需要修改为:
elif isinstance(sheet, xlrd.sheet.Sheet):
以解决`sheet`是元组的问题。
同时,`column_names`变量也应该修改为:
column_names = get_column_names(sheet)
这会确保在获取列名时使用正确的sheet对象。
非常抱歉之前的错误,还请您尝试使用修改后的代码。如有其他问题,请随时提问。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:44:42
FishC 发表于 2024-3-20 09:41
非常抱歉给您带来困惑。在代码中,我犯了一个错误。
原因在于,当您通过`workbook`获 ...
全部照这样修改后,报错:
请选择要操作的sheet:
1. Sheet1
请输入选项序号:1
Traceback (most recent call last):
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 99, in <module>
main()
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 70, in main
column_names = get_column_names(sheet)
~~~~~^^^
File "D:\Python\pythonProject\.venv\Lib\site-packages\openpyxl\worksheet\worksheet.py", line 298, in __getitem__
raise IndexError("{0} is not a valid coordinate or range".format(key))
IndexError: 0 is not a valid coordinate or range
FishC
发表于 2024-3-20 09:45:02
凊风 发表于 2024-03-20 09:44
全部照这样修改后,报错:
请选择要操作的sheet:
...
非常抱歉让您遇到了这个问题。根据错误提示,问题出现在`worksheet.py`文件的第298行,指示索引错误。这表明在获取列名时出现了问题。经过检查,发现在`get_column_names`函数中,对于`openpyxl`库的`sheet`对象的处理有误。具体来说,将以下代码:
elif isinstance(sheet, openpyxl.worksheet.worksheet.Worksheet):
return
修改为:
elif isinstance(sheet, openpyxl.worksheet.worksheet.Worksheet):
return .value for col in sheet.iter_cols(min_row=1, max_row=1)]
这样修改后,将正确获取列名信息。非常抱歉之前的错误和困惑,希望这次修改能够解决问题。如果还有其他疑问,请随时提问。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:47:18
FishC 发表于 2024-3-20 09:45
非常抱歉让您遇到了这个问题。根据错误提示,问题出现在`worksheet.py`文件的第298行,指示索引错误。 ...
请选择要操作的sheet:
1. Sheet1
请输入选项序号:1
请选择要转换格式的列:
1. 单位名
2. 姓名
3. 身份证号码
请输入选项序号:3
请选择转换后的单元格格式:
1. 文本
2. 日期
3. 数值
请输入选项序号:3
Traceback (most recent call last):
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 101, in <module>
main()
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 90, in main
converted_value = convert_cell_format(cell_value, cell_format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 48, in convert_cell_format
if isinstance(cell_value, (str, datetime.date)):
^^^^^^^^
NameError: name 'datetime' is not defined
FishC
发表于 2024-3-20 09:47:29
凊风 发表于 2024-03-20 09:47
请选择要操作的sheet:
1. Sheet1
请输入选项序号: ...
非常抱歉给您带来困扰。根据错误提示,代码在使用`datetime`模块时出现了命名错误。为了解决这个问题,我们需要在代码的开头处导入`datetime`模块。请将以下代码添加到代码开头:import datetime这样修改之后,代码应该能够正确地执行了。如果还有其他问题,请随时提问。谢谢!
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:50:32
FishC 发表于 2024-3-20 09:47
非常抱歉给您带来困扰。根据错误提示,代码在使用`datetime`模块时出现了命名错误。为了解决这个问题, ...
请选择要操作的sheet:
1. Sheet1
请输入选项序号:1
请选择要转换格式的列:
1. 单位名
2. 姓名
3. 身份证号码
请输入选项序号:3
请选择转换后的单元格格式:
1. 文本
2. 日期
3. 数值
请输入选项序号:3
Traceback (most recent call last):
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 102, in <module>
main()
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 91, in main
converted_value = convert_cell_format(cell_value, cell_format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\Xtt_xls\cell_format_change.py", line 50, in convert_cell_format
return float(cell_value)
^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '5324014001X'
对原本已经是数值型的单元格,应该继续向下判断和转换,而不应该报错。
FishC
发表于 2024-3-20 09:50:44
凊风 发表于 2024-03-20 09:50
请选择要操作的sheet:
1. Sheet1
请输入选项序号: ...
非常抱歉给您带来困扰。根据错误提示,代码在尝试将非浮点数字符串转换为浮点数时出现了错误。为了解决这个问题,我们可以修改`convert_cell_format`函数,对于已经是数值类型的单元格,直接返回原始值而不进行转换。请将以下代码替换`convert_cell_format`函数的内容:
def convert_cell_format(cell_value, cell_format):
# 根据用户指定的格式进行转换,这里只演示了两种常见的格式
if cell_format == '文本':
if isinstance(cell_value, (int, float, str)):
return str(cell_value)
else:
return cell_value
elif cell_format == '日期':
if isinstance(cell_value, str):
return datetime.datetime.strptime(cell_value, '%Y-%m-%d').date()
else:
return cell_value
elif cell_format == '数值':
if isinstance(cell_value, (int, float)):
return cell_value
elif isinstance(cell_value, str) and cell_value.isnumeric():
return float(cell_value)
else:
return cell_value
else:
return cell_value
这样修改之后,对于已经是数值型的单元格,程序将继续向下判断和转换,并将其作为浮点数保存。如果还有其他问题,请随时提问。谢谢!
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
凊风
发表于 2024-3-20 09:54:14
FishC 发表于 2024-3-20 09:50
非常抱歉给您带来困扰。根据错误提示,代码在尝试将非浮点数字符串转换为浮点数时出现了错误。为了解决 ...
身份证号(文本型)转换为”数值型”后,不要用科学计数法,并且后4位不应该全部变为0。