我是 Python 新手,我很难将这个 Javascript 箭头函数翻译成 Python。当我找到'\x1D'时,我无法制作我在JS中使用子字符串的部分来获取循环中的下3个值。任何提示或建议?
module.exports = edi => {
let decompressedEdi = ''
let lastCompressor = 0
for (let i = 0; i <= edi.length; i++) {
if (edi[i] === '\x1D') {
let decimal = parseInt(edi.substring(i + 1, i + 3), 16)
let repeater = edi[i + 3]
decompressedEdi +=
edi.substring(lastCompressor, i) + repeater.repeat(decimal)
lastCompressor = i + 4
}
}
decompressedEdi += edi.substring(lastCompressor, edi.length)
return decompressedEdi.replace(/(\r\n|\n|\r)/gm, '')
}
一只名叫tom的猫
慕姐8265434
相关分类