#使用分片、count和index实现将下列字符串按分隔符逗号分割成单项内容。要求不能使用字符串的其它方法。#测试数据:张三A1001男软件大专101班86779083#输出:张三#A1001#男#软件大专101班#86#77#90#83
s = "张三,A1001,男,软件大专101班,86,77,90,83" index = 0 while index < len(s): if s[index] == ',': index += 1 continue start = index while index < len(s) and s[index] != ',': index += 1 end = index print(s[start:end])
原文地址: https://www.cveoy.top/t/topic/iXxS 著作权归作者所有。请勿转载和采集!