python基本API

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、

      原文地址:https://www.cnblogs.com/buffer/p/1618644.html