前言
找到一个英文的游戏,想玩但英文水平不行,就尝试看能不能翻译下
找到一个文件发现里面全是这种格式的
MATERIALCATEGORYFOOD = “Food”,
MATERIALCATEGORYSTONE = “Stone”,
MATERIALCATEGORYWOOD = “Wood”,
MATERIALCATEGORYCLOTH = “Cloth”,
MATERIALCATEGORYLEATHER = “Leather”,
MATERIALCATEGORYMETAL = “Metal”,
MATERIALCATEGORYPLANT = “Plant”,
MATERIALCATEGORYBONE = “Bone”,
MATERIALCATEGORYCOMPONENT = “Consumable”,
很明显要翻译的是引号里面的
代码
import requests
import httplib2
import urllib
import random
import json
from hashlib import md5
import time
def updateFile(file):
"""
替换文件中的字符串
:param file:文件名
"""
file_data = ""
with open(file, "r", encoding="utf-8") as f:
for line in f:
if "=" in line:
index = line.partition('"')
#print(index[2])
index1 = line.partition('",'