如何在 Python 中拆分这个逗号分隔的字符串? [英] How can I split this comma-delimited string in Python?

查看:81
本文介绍了如何在 Python 中拆分这个逗号分隔的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关正则表达式的内容,我已经掌握了一些基本的资源.我现在一直在尝试用Re来整理这样的数据:

Hi I have been reading up about regular expressions, I have got some basic res working. I now have been trying to use Re to sort out data like this:

144,1231693144,26959535291011309493156476344723991336010898738574164086137773096960,26959535291011309493156476344723991336010898738574164086137773096960,1.00,4295032833,1563,2747941288,1231823695,26959535291011309493156476344723991336010898738574164086137773096960,26959535291011309493156476344723991336010898738574164086137773096960,1.00,4295032833,909,4725008"

"144,1231693144,26959535291011309493156476344723991336010898738574164086137773096960,26959535291011309493156476344723991336010898738574164086137773096960,1.00,4295032833,1563,2747941288,1231823695,26959535291011309493156476344723991336010898738574164086137773096960,26959535291011309493156476344723991336010898738574164086137773096960,1.00,4295032833,909,4725008"

...进入一个元组,但我无法让它工作.

...into a tuple but I cannot get it to work.

谁能解释一下他们将如何处理这样的事情?

Can anyone explain how they would go about something like this?

谢谢

推荐答案

您不想在这里使用正则表达式.

You don't want regular expressions here.

<代码> S = 144,1231693144,26959535291011309493156476344723991336010898738574164086137773096960,26959535291011309493156476344723991336010898738574164086137773096960,1.00,4295032833,1563,2747941 288,1231823695,26959535291011309493156476344723991336010898738574164086137773096960,26959535291011309493156476344723991336010898738574164086137773096960,1.00,4295032833,909,4725008"打印 s.split(',')

给你:

<代码> [ '144', '1231693144', '26959535291011309493156476344723991336010898738574164086137773096960', '26959535291011309493156476344723991336010898738574164086137773096960',1.00' '4295032833', '1563', '2747941 288', '1231823695', '26959535291011309493156476344723991336010898738574164086137773096960',' 26959535291011309493156476344723991336010898738574164086137773096960'、'1.00'、'4295032833'、'909'、'4725008']

这篇关于如何在 Python 中拆分这个逗号分隔的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆