2018年4月12日

文件操作练习题

摘要: ''' 1. 文件a.txt内容:每一行内容分别为商品名字,价钱,个数。 apple 10 3 tesla 100000 1 mac 3000 2 lenovo 30000 3 chicken 10 3 通过代码,将其构建成这种数据类型: [{'name':'apple','price':10,'a 阅读全文

posted @ 2018-04-12 16:04 python21-李伟 阅读(211) 评论(0) 推荐(0) 编辑

Python map() 函数

摘要: 语法 map() 函数语法: 参数 function -- 函数,有两个参数 iterable -- 一个或多个序列 实例 以下实例展示了 map() 的使用方法: >>>def square(x) : # 计算平方数 ... return x ** 2 ... >>> map(square, [1 阅读全文

posted @ 2018-04-12 15:21 python21-李伟 阅读(179) 评论(0) 推荐(0) 编辑

python split()使用方法

摘要: 描述 : 指定分隔符对字符串进行切片,如果参数 num 有指定值,则仅分隔 num 个子字符串 语法: split() 方法语法: str.split(str="", num=string.count(str)). 参数: str -- 分隔符,默认为所有的空字符,包括空格、换行(\n)、制表符(\ 阅读全文

posted @ 2018-04-12 12:29 python21-李伟 阅读(176) 评论(0) 推荐(0) 编辑

pythom os 模块

摘要: Python OS 文件/目录方法 os 模块提供了非常丰富的方法用来处理文件和目录。常用的方法如下表所示: os.access(path, mode) os.chdir(path) os.chflags(path, flags) os.chmod(path, mode) os.chown(path 阅读全文

posted @ 2018-04-12 10:53 python21-李伟 阅读(374) 评论(0) 推荐(0) 编辑

导航