1、生成随机数

  1. import random  
  2. rnd = random.randint(1,500);#生成1-500之间的随机数

2、读文件

  1. f = open("c:\\1.txt","r");  
  2. lines = f.readlines();#读取全部内容  
  3. for line in lines:  
  4.   print line 

3、写文件

  1. f = open("c:\\1.txt","r+");#可读可写模式  
  2. f.write("123");#写入字符串 

4、

 

5、

      相关文章:

      • 2021-05-22
      • 2021-05-15
      • 2021-10-02
      • 2021-09-20
      • 2021-10-18
      • 2021-05-25
      • 2022-12-23
      猜你喜欢
      • 2021-08-23
      • 2022-12-23
      • 2022-12-23
      • 2022-12-23
      • 2022-12-23
      • 2022-12-23
      • 2022-01-11
      相关资源
      相似解决方案