随笔分类 - 编程语言
摘要:环境搭建 FROM python:3.11.12-alpine3.21 LABEL maintainer=1209233066@qq.com RUN pip3 install starlette==0.46.2 uvicorn==0.34.1 mcp akshare pandas -i https:
阅读全文
摘要:迭代器 1.for 表达式 >>> [x for x in range(10)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> [(x,x-1) for x in range(10) if x%2==0] [(0, -1), (2, 1), (4, 3), (6, 5), (
阅读全文
摘要:# python 类支持封装、继承、多态 # 类名称首字符大写。建议遵循驼峰语法 # 第一行代码,定义一个空类 class FirstClass(object): pass # 类变量和 类方法 class SecondClass(object): name='张三' age=30 def intr
阅读全文
摘要:我们可以把不容易变动的功能放在父模板中,其他模板只需要继承改模板。 举例说明: 第一步创建父模板 # cat pod-parent.yaml.j2 apiversion: v1 kind: Pod metadata: {% block metadata %} {% endblock %} spec:
阅读全文
摘要:{# 这是一行注释 #} {{ name }} {# 定义变量 #} {% set age=32 %} {{ age }} {# 比较运算 #} {{ 1 == 1 }} {{ 1 != 1 }} {{ 1 > 1 }} {{ 1 >= 1 }} {{ 1 < 1 }} {{ 1 <= 1 }} {
阅读全文
摘要:第一步:生成目录结构 config_file |_templates | |_nginx.conf.j2 |_nginx.conf 第二步:写一个用于解析模板的函数 from jinja2 import PackageLoader,Environment def j2(package_name,pa
阅读全文
摘要:Jinja2 是一个 Python 的功能齐全的模板引擎。它有完整的 unicode 支持,一个可选 的集成沙箱执行环境,被广泛使用,以 BSD 许可证授权 pip install Jinja2==3.0.1 接下来我们测试模板解析 from jinja2 import Template templ
阅读全文
摘要:package main import ( "fmt" "net/http" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello, World
阅读全文
摘要:创建被调用的包 mkdir test cd test go mod init example.com/test cat test/test.go package test import "fmt" // func 定义函数 // Hello 函数名 // (name string) 可以接受一个字符
阅读全文
摘要:golang,本节目标为安装golang,并完成hello world 系统环境为win11,下载地址 安装后检查版本 PS C:\Users\pc> go.exe version go version go1.19.3 windows/amd64 设置国内包加速器 C:\> $env:GO111M
阅读全文
摘要:microblog |_app |_ __init__.py |_ routes.py #应用文件 |_ microblog.py #程序的入口 |_ .flaskenv #变量文件 执行app cd microblog; python -m flask run init.py # cat app/
阅读全文
摘要:import os,threading,requests ip=input('请输入要检测的ip:').strip().split('.')[0:3] ip='.'.join(ip) def detect(i): address=ip+'.%s'%i if os.name == 'nt': res=
阅读全文
摘要:第一章 <html> <!--解释器--> <!DOCTYPE html> <head> <!--字符集--> <meta http-equiv="content-type" content="text/html;charset=utf-8"/> <!--刷新跳转--> <meta http-equ
阅读全文
摘要:https://raw.githubusercontent.com/zhiwehu/Python-programming-exercises/master/100%2B%20Python%20challenging%20programming%20exercises.txt 100+ Python
阅读全文
摘要:import cv2 as cv import sys import time # 指定视屏存储解码格式 fourcc = cv.VideoWriter_fourcc(*'XVID') out = cv.VideoWriter('out.avi', fourcc, 20.0, (640, 480))
阅读全文
摘要:安装django docker run --net=host -it -v /home/django/code:/home/django python bash pip install django # python -m django --version 4.0.2 生成项目目录 # django
阅读全文
摘要:import pymysql connect=pymysql.connect(host="172.7.200.2",port=3306,user="root",passwd="123",db="mysql",charset="utf8") cursor=connect.cursor(pymysql.
阅读全文
摘要:简单的后台管理 1登录注册 2 老师 班级 学员 insert update delete 1.设计表结构 # 班级表 class CLASS(models.Model): caption = models.CharField(max_length=32) # 学生表 class STUDENT(m
阅读全文
摘要:import smtplib from email.mime.text import MIMEText from email.utils import formataddr # msg =MIMEText('正文:来自python的邮件','plain','utf-8') msg['From'] =
阅读全文
摘要:import threading import queue import os q= queue.Queue() for i in range(1,255): q.put(i) try: f = open('1.txt','a') def fun01(num): result=os.popen('p
阅读全文
浙公网安备 33010602011771号