摘要: # 统计一个字符串中各个字符个数 # # words="hello word" # wordsCount={} # for i in words: # if i!=" ": # wordsCount[i]=0 # for i in words: # if i != " ": # wordsCount[i] +=1 # print(wordsCoun... 阅读全文
posted @ 2018-08-09 11:44 studylady 阅读(413) 评论(0) 推荐(0) 编辑
摘要: #方法1 使用函数 def lenth1(lists): lists=lists.replace(" ","%20") # print(lists) return lists,len(lists) list1 = "Besttest andashu" b=lenth1(list1) # print(list1) print(b) # 使用for循环 def repla... 阅读全文
posted @ 2018-08-09 08:46 studylady 阅读(453) 评论(0) 推荐(0) 编辑
摘要: # 实现b的倒叙 c=b[::-1] print(c) # 使用join函数连接 d=" ".join(c) print("倒叙后显示",d) # 方法2 使用for循环 a="today is best" b=a.split() print(b) # 倒叙排序 c=b[::-1] print(c) list="" for x in c: list=list+x+" " prin... 阅读全文
posted @ 2018-08-08 17:32 studylady 阅读(124) 评论(0) 推荐(0) 编辑