我遇到了一个问题,在windows平台上与*nix平台上有额外的换行符。在
file = open('UTF16file.xml', 'rb')
html = file.read().decode('utf-16')
file.close()
regexp = re.compile(self.originalurl, re.S)
(html, changes) = regexp.subn(self.newurl, html)
file = open('UTF16file-regexed.xml', 'w+')
file.write(html.encode('utf-16'))
file.close()
在我的mac上运行这段代码可以工作-我可以不加任何换行符就把我的文件取回。到目前为止,我尝试过:
在Windows和OSX上,将正则表达式编码为utf-16,而不是对文件中断进行解码。
以“wb”模式而不是“w+”写入-在Windows上中断。
有什么想法吗?在
看起来像:
^{pr2}$(虽然当我把它从记事本粘贴到FF时,它实际上是在换行)…但是这个:
看起来像:
(在Windows XP SP3 32位上)
相关问题 更多 >
编程相关推荐