一、随机数生成
import random
#生成1-1000之间的伪随机数
num = random.randint(1,1000)
二、读文件
read = open("c:\\text.txt","r")
lines = read.readlines()
for line in lines:
print (line)
三、写文件
w = open("c:\\test.txt","r+")
w.write("123")
四、连接数据库
import MySQLdb
conn = MySQLdb.connect (host='localhost',databse='test',user='test',password='123')
sql= conn.cursor()
sql.execute("select * from test")
print (sql.rowcount)
标签:文件,Python,读写,生成,随机数,sql,test,数据库
From: https://www.cnblogs.com/python1111/p/16932620.html