我想列出字符串后面的字符串。你知道吗
STUDENT
a john
a anny
SUBJECT
b math
b physical
CLASS
a one
a two
a three
STUDENT
a pone
b julia
b sopia
CLASS
a four
a five
PROFESSOR
b uno
b sonovon
PROFESSOR
b jone
我的目标是删除重复的主题和加入内容。你知道吗
主题可以是随机的上弦。你知道吗
但是内容必须是start a
或b
我该怎么做?你知道吗
Tags:
因为关于主题的唯一信息是它们是上字符串,所以可以使用
isupper()
谓词按以下方式拆分文件:注意:我假设您的字符串存储在一个文件中
只需以主语为键对dict中的元素进行分组:
输出:
我的目标是删除重复主题并加入内容。很明显这就是你想要的。你知道吗
OrderedDict将保持有序,如果您想将更新的行写入文件,只需重新打开并在迭代时写入即可。items?你知道吗
新输出,由主题连接:
相关问题 更多 >
编程相关推荐