新风花雪月 发表于 2017-4-30 12:45:44

python文件操作(1)

  # -*- coding:utf-8 -*- #
  #写文件
  myfile = open('hello world','w');
  myfile.write('hello world');
  myfile.close();
  #读文件
  myfile = open('hello world','r');
  str = myfile.readline();
  print("文件内容:\n" + str);
  OutPut
  文件内容:
  hello world
页: [1]
查看完整版本: python文件操作(1)