python字符串拆分“约80k个字符的字符串”

时间:2018-10-29 07:21:02

标签: string python-3.x list

一些数据样本在这里

f = "optimal after sales service. Our customer friendly support system is truly one of a kind giving A Avon Watches a pride of place in the world of Indian watches.\\t0210PBH2YCA\\t1002004\\t499\\t\\t2015-02-10 16:43:27 IST\\t\\ty\\t1\\t\\t\\t11\\t\\t\\t\\tB00TFCNTGG\\t\\t\\t\\t\\t\\tB00TFCNTGG\\t\\t\\t\\tAMAZON_IN\\t\\tMigrated Template\\tActive\\t499.0\\nA Avon Sports Digital Black Dial Men\\\'s watch - 1002008\\tMulti functional Design Watch For Children\\\'s ; Tough Watch Case ; Stainless Steel Back ;Power Battery ; Tab For Date,Month & Multiple Light Effect ; Day & Time Display Together ; Stop Watch ; Calendar ; 12-24 Hour Time Display Option. A Avon Watches are Well known for amazing style and powerful features. The inbuilt features specify their usability. The elegantly designed A Avon Watches are apt to complement formal wear. A Avon Watches built with fine skills is backed by optimal after sales service. Our customer friendly support system is truly one of a kind giving A Avon Watches a pride of place in the world of Indian watches.\\t0216PZ3I06Y\\t1002008\\t499\\t\\t2015-02-16 15:45:58 IST\\t\\ty\\t5\\t\\t\\t11\\t\\t\\t\\tB00TOCAJ4C\\t\\t\\t\\t\\t\\t52E478CC519D7B2D\\t\\t\\t\\tAMAZON_IN\\t\\tMigrated Template\\tActive\\t499.0\\nA Avon Sports Digital Black Dial Women\\\'s Watch - 1002013\\tWatch Design For Children, Boys & Girls. A Avon Watches are Well known for amazing style and powerful features. The inbuilt features specify their usability. The elegantly designed A Avon Watches are apt to complement formal wear. A Avon Watches built with fine skills is backed by optimal after sales service. Our customer friendly support system is truly one of a kind giving A Avon Watches a pride of place in the world of Indian watches.\\t0216PZCK1E4\\t1002013\\t599\\t\\t2015-02-16 18:17:39 IST\\t\\ty\\t5\\t\\t\\t11\\t\\t\\t\\tB00TOGJ00M\\t\\t\\t\\t\\t\\t52E49B861FA1FF25\\t\\t\\t\\tAMAZON_IN\\t\ "
z=f.split("\\\t")
for i in z:
  print(i)
  print(len(z))

,但未拆分,它按原样打印相同的文件。 我也检查了z的长度,也显示了1。

该怎么做?

1 个答案:

答案 0 :(得分:1)

您的文本不包含任何标签'\t',为什么会发生拆分?有很多反斜杠\\,后跟一个简单的t,但您尝试在反斜杠上进行分割,后跟制表符。您可以尝试:

f.split('\\t')

看看区别。

相关问题