标签:enc address end sts ipad 动画设计 数据库 container 运行
#Dockerfile
FROM python:3 #工作路径 WORKDIR /usr/src/app #拷贝文件 COPY requirements.txt ./ #根据requirement.txt安装项目所需包 RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.douban.com/simple #指定容器启动时默认要运行的程序 CMD [ "python", "./hello.py" ]
#requirement.txt
PyMySQL
opencv-python
print("hello world!")
import calendar yy = int(input("输入年份: ")) mm = int(input("输入月份: ")) print(calendar.month(yy,mm))
import pymysql class Mysql(): def __init__(self,ipaddress,urname,pd,db_name,table_name): self.ip=ipaddress self.username=urname self.password=pd self.db_name=db_name self.table_name=table_name def connect(self): self.conn=pymysql.connect(self.ip,self.username,self.password,self.db_name) if(self.conn!=None): print("yes") self.cursor=self.conn.cursor() def createtable(self,sql): self.cursor.execute(‘drop table if exists %s;‘ %self.table_name) self.cursor.execute(sql) def insertdata(self,sql): try: self.cursor.execute(sql) self.conn.commit() except : self.conn.rollback() def selectall(self): sql=‘select * from %s‘ %self.table_name self.cursor.execute(sql) return self.cursor.fetchall() def updatedata(self): try: self.cursor.execute(sql) self.conn.commit() except : self.conn.rollback() def deletedata(self): try: self.cursor.execute(sql) self.conn.commit() except : self.conn.rollback() def close(self): self.conn.close() ip=‘lnmp_mysql-container‘ #容器名 username=‘root‘ #用户名 password=‘123‘ #密码 db_name=‘myDB‘ #数据库名 table_name=‘Stu‘ #表名 db=Mysql(ip, username, password, db_name,table_name) db.connect() sql="""create table Stu ( id varchar(10) primary key, name varchar(20) );""" db.createtable(sql) sql1="insert into Stu values(123,‘abc‘);" sql2="insert into Stu values(456,‘bcd‘);" db.insertdata(sql1) db.insertdata(sql2) print(db.selectall()) db.close()
import cv2 as cv img1 = cv.imread("photo1.png") img2 = cv.imread("photo2.png") result = cv.addWeighted(img1,0.3,img2,0.3,0) cv.imwrite(‘re.png‘, result) print("success!")
标签:enc address end sts ipad 动画设计 数据库 container 运行
原文地址:https://www.cnblogs.com/jay-home/p/12940356.html