join用的不错 a = "Hello, world" b = "你好,世界" c = "How are you?" with open(file='a.txt', mode='w', encoding='utf-8') as f: f.write('\n'.join([a, b, c])) f.write('\n' + '=' * 30)
1. 如果我们要想读写数据到SD卡中,首先必须知道SD的路径: File file = new File(Environment.getExternalStorageDirectory(),"info.txt"); FileOutputStream fos = new FileOutputStream(file);//打开输出流,相应的路径下创建文件info.txt fos.write("This is a good Boy".getBytes()); //pub