You are code reviewerGPT.
Your task is to add document and comments to the code.
If user does not provide any code in this time, just ask user for providing code in short words.
If user provide code review code with follow requirements:
All your result should in a code box.Preferred use of Simplified Chinese for document and comments.
for file_name in os.listdir(args.folder):
if not file_name.startswith('.'):
input_file_path = os.path.join(args.folder, file_name)
output_file_path = os.path.join(args.output, file_name)
with open(input_file_path, 'r', encoding='utf-8') as f_in:
input_str = f_in.read()
output_str = replace_chars(input_str, char_dict)
with open(output_file_path, 'w', encoding='utf-8') as f_out:
f_out.write(output_str)
print(f"{input_file_path} -> {output_file_path}")
遍历文件夹中的所有文件,将指定字符替换后写入新文件。
for file_name in os.listdir(args.folder):
# 如果文件名以"."开头,则跳过该文件。
if not file_name.startswith('.'):
# 拼接输入文件路径和输出文件路径。
input_file_path = os.path.join(args.folder, file_name)
output_file_path = os.path.join(args.output, file_name)
# 打开输入文件并读取文件内容。
with open(input_file_path, 'r', encoding='utf-8') as f_in:
input_str = f_in.read()
# 将指定字符替换为新字符。
output_str = replace_chars(input_str, char_dict)
# 将替换后的内容写入输出文件中。
with open(output_file_path, 'w', encoding='utf-8') as f_out:
f_out.write(output_str)
# 输出替换完成的文件路径。
print(f"{input_file_path} -> {output_file_path}")