一个是分割,一个是连接. 惯例,先看内部帮助文档 Help on method_descriptor: join(...) S.join(iterable) -> string Return a string which is the concatenation of the strings in the iterable. The separator between elements is S. (END) 将可迭代对象(包含的应该是str类型的,不然会报错)连接起来, 返回值是str,用法如…
1.map(function,iterable) map是把迭代对象依次进行函数运算,并返回. 例子: map返回的十分map对象,需要list()函数转化. 2.exec()函数 执行储存在字符串或文件中的 Python 语句,相比于 eval,exec可以执行更复杂的 Python 代码. Execute the given source in the context of globals and locals. 在全局变量和局部变量上下文中执行给定的源. The source may be…
目录 说明 数据说明 正确示例 错误示例 解决办法 说明 最近在用Python的join函数连接多个列表时,出现了如下两个错误,即合并类型不一致.折腾了很久才找到原因,真是基础不牢,地动山摇. TypeError: sequence item 3: expected str instance, int found 或 TypeError: can only concatenate list (not "str") to list 数据说明 a = ['a','c','c'] b = […
#!/usr/bin/python import os def get_env_varible(key): return os.getenv(key) if __name__ == '__main__': key1 = "COMPUTERNAME" var1 = get_env_varible(key1) print "The value of %s in system enviroment is %s" %(key1, var1) 测试目的: 验证根据关键字key…