list = ['2','4','3','9','1','7']     # 列表 tul = ('a','b','b','e','b')          # 元组 k={'name':'zhouyuyao','age':21}      # 字典 f=codecs. list = ['2','4','3','9','1','7']     # 列表 tul = ('a','b','b','e','b')          # 元组 k={'name':'zhouyuyao','age':21}      # 字典 f=codecs.open('write.txt','w')       # w 表示写 f.write('Hello world\n')             # 将字符串写入文件 f.writelines(str(list)+'\n')         # 将列表写入文件 f.writelines(str(tul)+'\n')          # 将元组写入文件 #f.writelines(tul)                   # 将元组写入文件 f.writelines(str(k)+'\n')            # 将字典写入文件 #f.writelines(k)                     # 将字典写入文件

返回结果:新建了一个write.txt,内容如下

Hello world

['2', '4', '3', '9', '1', '7']

('a', 'b', 'b', 'e', 'b')

{'name': 'zhouyuyao', 'age': 21}

【剑指offer知识点】List转int[],List转String,String转int,char[]转String,String 转char[],List转String[]
【剑指offer知识点】List转int[],List转String,String转int,char[]转String,String 转char[],List转String[]
List<String> 和 ArrayList<String>的区别(简单易懂)
声明ArrayList list=new ArrayList()与List list=new ArrayList()都是可以的,但是前者不推荐,因为后者声明的对象更灵活。
分布式服务器框架之Servers.Common中使用CSRedis测试操作Redis中的string、hash_table、list、set、zset
在Servers.Common类库总创建了一个TestRedis.cs文件,我是在Servers.GameServer中去初始化的。主要是测试了Redis中常用的数据类型和常用的API,有一些不常用的可能没有写。需要详细了解API的话可以安装上CSRedis之后F12追进去查看,上面有详细的API说明。
初阶C++——STL——string类、vector类和list类(使用方法+模拟实现+测试+思路分析)
Alexander Stepanov、Meng Lee 在惠普实验室完成的原始版本,本着开源精神,他们声明允许任何人任意运用、拷贝、修改、传播、商业使用这些代码,无需付费。唯一的条件就是也需要向原始版本一样做开源使用。 HP 版本--所有STL实现版本的始祖。
[Flutter]足够入门的Dart语言系列之变量的类型:bool、String、num、List、Set和Map
变量的类型指的是变量的特性或特征,比如表示数字类型、文本类型、集合类型等,表示的是一类数据。 Dart提供以下类型:int, double、String、List、Set、Map、null...
一步一步学习Redis——五大数据类型(String、Hash、List、Set、ZSet)简要介绍
一步一步学习Redis——五大数据类型(String、Hash、List、Set、ZSet)简要介绍