
python
houfeihi123
日常悠哉悠哉!!!(* ̄︶ ̄)
展开
-
python3 调用 k8s API
一、安装:方式1:github:https://github.com/kubernetes-client/pythonpip3 install kubernetes方式2: 1、将python_k8s.tar.gz文件解压到' /usr/lib/python3.x'二、认证1、kubeconfig文件认证首先引入SDK支持库。然后将 ~/.kube 的config文件的内容复制到本地目录,保存为文件kubeconfig.yaml,然后运行下面的python代码。...原创 2020-08-20 16:48:12 · 4399 阅读 · 0 评论 -
python - mysql socket
server端:#!/usr/bin/python# -*- coding: UTF-8 -*-# 文件名:server.pyimport socket # 导入 socket 模块s = socket.socket() # 创建 socket 对象host = socket.gethostname() # 获取本地主机名port = 12345 # 设置端口s.bind((host, port)) # 绑定端口s.listen(5) # 等待客户端连接while.原创 2020-08-19 20:58:42 · 183 阅读 · 0 评论 -
python - mysql SMTP邮件
import smtplibfrom email.mime.text import MIMEText# 第三方 SMTP 服务mail_host = "smtp.qq.com" # SMTP服务器mail_user = "1032796xxx@qq.com" # 用户名mail_pass = "xxxxxxxxx" # 授权密码,非登录密码sender = "1032796xxx@qq.com" # 发件人邮箱(最好写全, 不然会失败)receivers = ['1032796x.原创 2020-08-19 20:56:01 · 372 阅读 · 0 评论 -
python - mysql查询
import pymysqldb = pymysql.connect("172.16.27.130", "root", "Hou.fei12345", "hou")# 使用cursor()方法获取操作游标cursor = db.cursor()# SQL 查询语句sql = "SELECT * FROM EMPLOYEE \ WHERE INCOME > %s" % (1000)try: # 执行SQL语句 cursor.execute(sql)...原创 2020-08-19 20:53:46 · 212 阅读 · 0 评论 -
python - mysql更新
import pymysqldb = pymysql.connect("172.16.27.130", "root", "Hou.fei12345", "hou")cursor = db.cursor()sql = "UPDATE EMPLOYEE SET AGE = AGE + 1 WHERE SEX = '%c'" % ('M')try: cursor.execute(sql) db.commit()except: db.rollback()db..原创 2020-08-19 20:52:18 · 311 阅读 · 1 评论 -
python - mysql 插入
import pymysql# 打开数据库db = pymysql.connect("172.16.27.130", "root", "Hou.fei12345", "hou")# 使用 cursor() 方法创建一个游标对象 cursorcursor = db.cursor()# 插入sql语句sql = """INSERT INTO EMPLOYEE(FIRST_NAME, LAST_NAME, AGE, SEX, INCOME) VALUES (.原创 2020-08-19 20:51:37 · 238 阅读 · 0 评论 -
python - mysql建表
import pymysql# 打开数据库db = pymysql.connect("172.16.27.130", "root", "Hou.fei12345", "hou")# 使用cursor()方法创建光标cursor = db.cursor()# 如果表已经存在,使用execute() 删除表cursor.execute("drop table if EXISTS EMPLOYEE")# 创建数据表SQL语句sql = """CREATE TABLE EMPLOYEE (.原创 2020-08-19 20:50:57 · 950 阅读 · 1 评论