path = r'c:/NeoZQYY/apps/miniprogram/miniprogram/pages/performance-records/performance-records.ts' with open(path, 'rb') as f: content = f.read().decode('utf-8') content = content.replace( " totalHours: '0h',\r\n totalIncome: '\xa50',", " totalHours: '0h',\r\n totalHoursRaw: '0h',\r\n totalIncome: '\xa50'," ) content = content.replace( " totalHours: '59.0h',\r\n totalIncome: '\xa54,720',", " totalHours: '59.0h',\r\n totalHoursRaw: '60.5h',\r\n totalIncome: '\xa54,720'," ) with open(path, 'wb') as f: f.write(content.encode('utf-8')) print('done')