完善
This commit is contained in:
25
search_encoding.py
Normal file
25
search_encoding.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
|
||||
search_string = "分析商品销售数据和趋势"
|
||||
utf8_bytes = search_string.encode('utf-8')
|
||||
gbk_bytes = search_string.encode('gbk')
|
||||
|
||||
found_files = []
|
||||
|
||||
for root, dirs, files in os.walk('.'):
|
||||
for file in files:
|
||||
if file.endswith(('.uvue', '.md', '.json', '.js', '.uts', '.ts')):
|
||||
filepath = os.path.join(root, file)
|
||||
abs_path = os.path.abspath(filepath)
|
||||
try:
|
||||
with open(filepath, 'rb') as f:
|
||||
content = f.read()
|
||||
if utf8_bytes in content:
|
||||
found_files.append((abs_path, 'UTF-8'))
|
||||
elif gbk_bytes in content:
|
||||
found_files.append((abs_path, 'GBK'))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for path, enc in found_files:
|
||||
print(f"{path}")
|
||||
Reference in New Issue
Block a user