题目:
字符串 "axbyczdj",如果得到结果“abcd”
方法一:
''' 字符串 "axbyczdj",如果得到结果“abcd” ''' string1 = 'axbyczdj' new_list = [] string1_list = list(string1) for letter in string1_list: if letter in 'abcd': new_list.append(letter) print('新的字符串是:' + ''.join(new_list))
题目:
字符串 "axbyczdj",如果得到结果“abcd”
方法一:
''' 字符串 "axbyczdj",如果得到结果“abcd” ''' string1 = 'axbyczdj' new_list = [] string1_list = list(string1) for letter in string1_list: if letter in 'abcd': new_list.append(letter) print('新的字符串是:' + ''.join(new_list))