python3.5变化(String)
2016-04-08 10:49
459 查看
2.7代码实现查询字符串内字符的数量
但我用的是3.5,
import string def letterCount(str): count = 0 for s in str: if s.lower() in string.lowercase: print() count += 1 return count question = "What is your name?" print(letterCount(question))
但我用的是3.5,
string.lowercase找不到,查找后发现是做了改变。代码如下:
import string def letterCount(str): count = 0 for s in str: if s.lower() in string.ascii_lowercase: print() count += 1 return count question = "What is your name?" print(letterCount(question))
相关文章推荐
- Python3.5.1 下使用HTMLParser报错
- Head First Python 学习札记 2016-04-07
- Python:文件的读取、创建、追加、删除、清空
- leetcode @python 135. Candy
- Day6、Python
- elasticsearch,python包pyes进行的处理
- leetcode @python 134. Gas Station
- 据廖雪峰python3教程----python学习第九天
- python调用fortran模块
- Python读取绝对路径下的文件的问题
- 安装Python和pip
- python学习笔记(excel简单操作)
- 【python学习】日志文件里IP访问最多的3个
- leetcode @python 133. Clone Graph
- leetcode @python 132. Palindrome Partitioning II
- leetcode @python 131. Palindrome Partitioning
- Python学习笔记day12
- python(12)给文件读写上锁
- 统计中文分词(最大熵)
- Python基础教程(第2版•修订版)代码清单2-3 勘误