for循环一样容易阅读。
my_string = "blah, lots , of , spaces, here "result = [x.strip() for x in my_string.split(',')]# result is ["blah", "lots", "of", "spaces", "here"]
请参阅:
有关列表理解的Python文档
很好的2秒钟的列表理解说明。
欢迎分享,转载请注明来源:内存溢出
for循环一样容易阅读。
my_string = "blah, lots , of , spaces, here "result = [x.strip() for x in my_string.split(',')]# result is ["blah", "lots", "of", "spaces", "here"]
请参阅:
有关列表理解的Python文档
很好的2秒钟的列表理解说明。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)