看了一些网上的解释,最主流的解释是“str是给人看的,repr是给机器看的”,如果已经理解了的,这句话是对的,但是是有问题的,对于没懂的,这句话是无法理解的. 我来尝试解释一下.先直译一下官方文档: repr(object) Return a string containing a printable representation of an object. For many types, this function makes an attempt to return a string tha
字符串常用操作 移除空白 分割 长度 索引 切片 class str(basestring): """ str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object. """ def capitalize(self): &q
Python中定义常量 都用大写 Pip 安装python第三方模块的命令 一般默认都放在/python27/lib/site-pak List.count(‘元素’)-------------统计list中有几个相同的元素 List.index(‘元素’)---------返回当前(第一个出现的)元素的下标 通过下标来修改list中的相同的值 for i in range(lis.count(90)): nn = lis.index(90) lis[nn] = 999999999