gpt4 book ai didi

python - 如何拆分字符串中的两个项目?

转载 作者:太空宇宙 更新时间:2023-11-04 07:09:56 24 4
gpt4 key购买 nike

<分区>

使用 .read() 读取一个文件,我如何同时拆分两个对象?我试图同时使用逗号和 "\n" 进行拆分,但是当我首先使用逗号进行拆分时,它会将我的字符串变成一个列表,我无法在其中再次拆分。

这是我要拆分的字符串:

'各州,总分,批判性阅读,数学,写作,参与度 (%)\nWashington,1564,524,532,508,41.2000\nNewHampshire,1554,520,524,510,64.0000\nMassachusetts,1547,512,526,509,72.1000\n\n 1546,523,524,499,37.1000\n佛蒙特州,1546,519,512,506,64.0000\n亚利桑那州,1544,519,525,500,22.4000\n康涅狄格州,1536,509,514,513,71.2000\n阿拉斯加,185151,5,185151,5 0\n弗吉尼亚,1521,512,512,497,56.0000\n加利福尼亚,1517, 501,516,500,37.5000\n新泽西州,1506,495,514,497,69.0000\n马里兰州,1502,501,506,495,56.7000\n北卡罗来纳州,1485,497,511,477,45.5000\n罗德岛州,9,5,9.484,147 000\n印第安纳州,1476,494,505,477,52.0000\n佛罗里达州,1473,496,498,479, 44.7000\n宾夕法尼亚州,1473,492,501,480,62.3000\n内华达州,1470,496,501,473,25.9000\n特拉华州,1469,493,495,481,59.2000\n得克萨斯州,1462,484,501.New4703,4 484,499,478,59.6000\n夏威夷,1458,483,505,470,47.1000\n佐治亚州,1453,488,490,475,46.5000\n南卡罗来纳州,1447,484,495,468,40.7000\n缅因州,1389,468,467,454,87.1000\n爱荷华州,1798,603,613,582,2.7000\n7,80,6,5,9 明尼苏达州.0000\n威斯康星州,1778,595,604,579,3.8000\n密苏里州, 1768,593,595,580,3.6000\n密歇根州,1766,585,605,576,3.8000\n南达科他州,1766,592,603,571,2.0000\n伊利诺伊州,1762,585,600,577,4.6700\n堪萨斯州,1750,755,59内布拉斯加州,1746,585,593,568,3.9000\n北达科他州,1733, 580,594,559,3.4000\n肯塔基州,1713,575,575,563,5.0000\n田纳西州,1712,576,571,565,6.4000\n科罗拉多州,1695,568,572,555,14.1000\n阿肯色州,1683,565,565kl,5 ahoma,1684,569,568,547,3.8000\n怀俄明州,1683,570,567,546, 3.6000\n犹他州,1674,568,559,547,4.5000\n密西西比州,1666,566,548,552,2.2000\n路易斯安那州,1652,555,550,547,4.0000\n阿拉巴马州,1650,556,550,544,5.45ex,550,544,5.45ex 49,534,7.1000\n俄亥俄州,1609,538,548,522,17.2000\n爱达荷州,1601,543,541,517,14.6000\n蒙大拿州,1593,538,538,517,20.0000\n西弗吉尼亚州,1522,515,507,500,13.2000\n'

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com