9 lines
265 B
Python
9 lines
265 B
Python
"""CSV 导出的通用安全处理。"""
|
|
|
|
|
|
def csv_safe_value(value):
|
|
"""防止电子表格将文本解释成公式。"""
|
|
if isinstance(value, str) and value.lstrip().startswith(('=', '+', '-', '@', '\t', '\r')):
|
|
return "'" + value
|
|
return value
|