расщепление строки python "строка длиной около 80 тыс. символов" - PullRequest
0 голосов
/ 29 октября 2018

некоторые образцы данных здесь

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 голосов
/ 29 октября 2018

Ваш текст не содержит вкладок '\t' Так почему же произошло разделение? Существует много обратных слешей \\, за которыми следует простой t, но вы пытаетесь разделить их на обратные слэши, а затем вкладку. Вы можете попробовать:

f.split('\\t')

и увидите разницу.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...