输入字符串是:
InputStr1 = 'this-is-a-boy-5';
InputStr2 = 'this23-is-a-boy-10';
InputStr3 = 'this-41';
Run Code Online (Sandbox Code Playgroud)
输出应该是:
Output1 = ['this-is-a-boy'] [5]
Output2 = ['this23-is-a-boy'] [10]
Output3 = ['this'] [41]
Run Code Online (Sandbox Code Playgroud)
我想将这些字符串分成两部分,这样我就可以将第一个字符串和最后一个字符分开.我试过strsplit()但它没有帮助.
我有一个python列表
my_list = ['owner/NN', 'is/VBZ', 'pleasant/JJ', 'and/CC', 'entertaining/JJ', './.']
Run Code Online (Sandbox Code Playgroud)
我想将它分成两部分(基于每个列表元素中显示的分隔符'/'),这样我就可以得到两个单独的列表
my_list_1 = ['owner', 'is', 'pleasant', 'and', 'entertaining', '.']
my_list_2 = ['NN', 'VBZ', 'JJ', 'CC', 'JJ', '.']
Run Code Online (Sandbox Code Playgroud)