py学习
吃不尽的lemon
——What's the secret to good comedy?
——Timing.
——And what's courage?
——Grace under pressure.
——Who's the boss?
——I'm the boss.
展开
-
python 统计字符串每个单词出现的次数
方法一:sentence = “I can because i think i can”result = {word: sentence.split().count(word) for word in set(sentence.split())}print(result)方法二:def count(str):count_words = str.split()count_word = {}for word in count_words:if word not in count_word.ke转载 2020-09-07 16:55:03 · 4170 阅读 · 0 评论 -
python字符串
Python的字符串python字符串是以Unicode编码的,也就是说,Python的字符串支持多语言对于单个字符的编码,Python提供了ord()函数获取字符的整数表示,chr()函数把编码转换为对应的字符ord('A')65ord('中')20013chr(66)'B'chr(25991)'文''\u4e2d\u6587''中文'如果知道字符的整数编...转载 2019-03-15 22:24:54 · 76 阅读 · 0 评论 -
python
python语言程序设计一基本语法元素1.温度转换实例#TempConvert.pyTempstr=input("please input a figure with sigh:")if Tempstr[-1] in ['F','f']: C=(eval(Tempstr[0:-1])-32)/1.8 print("result is:{:.2f}C"....原创 2019-03-15 21:42:50 · 170 阅读 · 0 评论