- Katılım
- 22 Eki 2024
- Konular
- 27
- Mesajlar
- 265
- Online süresi
- 1ay 2g
- Reaksiyon Skoru
- 165
- Altın Konu
- 0
- Başarım Puanı
- 74
- TM Yaşı
- 1 Yıl 5 Ay 29 Gün
- MmoLira
- 2,008
- DevLira
- 42
Metin2 EP, Valorant VP dahil tüm oyun ürünlerini en uygun fiyatlarla bulabilir, Item ve Karakterlerinizi hızlıca satabilirsiniz. HEMEN TIKLA!
Anlatım hazırlayacağım devamı gelecek.
std:::
import os
import re
def read_file_with_fallback(file_path):
encodings = ['utf-8', 'latin-1', 'cp1252']
for enc in encodings:
try:
with open(file_path, 'r', encoding=enc) as file:
return file.readlines(), enc
except UnicodeDecodeError:
continue
raise UnicodeDecodeError(f"Dosya {file_path} uygun bir şekilde okunamadı.")
def convert_to_std_syntax(file_path):
lines, encoding_used = read_file_with_fallback(file_path)
replacements = [
(r'(?<!std::)(?<!\w)(string)(?!\w)', r'std::string'),
(r'(?<!std::)(?<!\w)(pair)(?!\w)', r'std::pair'),
(r'(?<!std::)(?<!\w)(make_pair)(?!\w)', r'std::make_pair'),
(r'(?<!std::)(?<!\w)(vector)(?!\w)', r'std::vector'),
]
updated_lines = []
for line in lines:
if line.strip().startswith("#include"):
updated_lines.append(line)
continue
for pattern, replacement in replacements:
line = re.sub(pattern, replacement, line)
updated_lines.append(line)
with open(file_path, 'w', encoding=encoding_used) as file:
file.writelines(updated_lines)
def process_directory(directory):
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(('.cpp', '.h')):
file_path = os.path.join(root, file)
print(f"Processing: {file_path}")
try:
convert_to_std_syntax(file_path)
except Exception as e:
print(f"Hata oluştu: {e} (Dosya: {file_path})")
project_directory = "."
process_directory(project_directory)
- Durum
- Üzgünüz bu konu cevaplar için kapatılmıştır...




