本文介绍了退格分隔的平面文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人看过以空格分隔的平面文件?我的要求是解析这样的文件,但是我无法在文件中放入退格字符以检查是否能够检测到它。
Has any one ever seen a backspace delimited flat file? My requirement is to parse such a file but I am not able to put a backspace character into a file to check if I am able to detect it.
推荐答案
拆分应该比使用任何其他定界符更难。毕竟,这只是另一个角色。在Python中,例如:
Splitting shouldn't be any harder than using any other delimiter. It's just another character, after all. In Python, for instance:
>>> x = "apples\bbanana\bcoconut\bthese are delicious!"
>>> x.split('\b')
['apples', 'banana', 'coconut', 'these are delicious!']
大多数语言都使用 \b
作为退格符。如果不是,则还可以包含退格符本身的ASCII控制代码,即\x08。
Most languages use \b
as the escape character for a backspace. If yours doesn't you can also include the ASCII control code for backspace itself, which is \x08.
这篇关于退格分隔的平面文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!