标签:rms int nbsp ret term spl def div 面试
str1 = "k:1|k1:2|k2:3|k3:4" def str2dict(str1): dict1 = {} for iterms in str1.split(‘|‘): key,value = iterms.split(‘:‘) dict1[key] = value return dict1 #字典推导式 d = {k:int(v) for t in str1.split("|") for k, v in (t.split(":"), )}
标签:rms int nbsp ret term spl def div 面试
原文地址:https://www.cnblogs.com/Fiona-Y/p/10567255.html