- 博客(36)
- 收藏
- 关注
原创 python3-leetcode-118. 杨辉三角
https://leetcode-cn.com/problems/pascals-triangle/ class Solution: def generate(self, numRows: int) -> List[List[int]]: result = [] for i in range(numRows): d= [1]*(i+1) if i >=2: f.
2021-10-05 22:43:53
329
原创 python3-leetcode-53. 最大子序和
https://leetcode-cn.com/problems/maximum-subarray/ class Solution: def maxSubArray(self, nums: list[int]) -> int: if len(nums) <=1: return sum(nums) vs = [0]*len(nums) vs[0]= nums[0] result = num.
2021-10-05 22:40:20
333
原创 python3-leetcode-121. 买卖股票的最佳时机
https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/ class Solution: def maxProfit(self, prices: List[int]) -> int: if len(prices)<=1: return 0 minp,maxp = prices[0],0 for p in prices[1:]:.
2021-10-05 21:28:28
347
原创 python3-leetcode-5881. 增量元素之间的最大差值
https://leetcode-cn.com/contest/weekly-contest-260/problems/maximum-difference-between-increasing-elements/ GitHub - w5678/leetcode-2021: Learn and Share class Solution: def maximumDifference(self, nums: list[int]) -> int: maxdiff =
2021-09-26 20:48:37
363
原创 python3-leetcode-2000. 反转单词前缀
https://github.com/w5678/leetcode-2021https://github.com/w5678/leetcode-2021力扣 class Solution: def reversePrefix(self, word: str, ch: str) -> str: idx = word.find(ch) return word if idx== -1 else word[0:idx+1][::-1]+ wor...
2021-09-26 20:16:45
317
原创 leetcode-python3-1759. 统计同构子字符串的数目
https://leetcode-cn.com/problems/count-number-of-homogenous-substrings/https://leetcode-cn.com/problems/count-number-of-homogenous-substrings/https://github.com/w5678/leetcode-2021https://github.com/w5678/leetcode-2021 class Solution: def countHomo
2021-09-25 21:19:16
322
原创 leetcode-python3-1758. 生成交替二进制字符串的最少操作数
我的题解: class Solution: def minOperations(self, s: str) -> int: return min(self.startWith1(s),self.startWith0(s)) def startWith1(self,s:str) -> int: i,cnt=0,0 key=0 maps={ 1:"1", 0:"...
2021-09-25 20:44:02
328
原创 Golang-报错-go get github/xxx
> go get github.com/gin-gonic/gin ... exit status 128: fatal: git fetch-pack: expected shallow list Root cause: 是git的问题,请升级git到最新版本,就好了
2021-09-20 16:12:54
312
原创 Golang-基础-linux执行权限问题
我们正常把编译过的二进制copy到server的tmp下验证 chmod 777 hello ./hello 会报错: fork/exec /tmp/go-build584080616/b001/exe/hello: permission denied 原因是: 在go中不认/tmp/目录 将hello 移动到其他目录执行就行了 ...
2021-09-20 11:01:12
975
原创 Golang-基础-交叉编译
GOOS=windows GOARCH=amd64 go build -o hello hello.go GOARCH, 目标平台的 CPU 架构. 常用的值amd64,arm64,i386,armhf GOOS, 目标平台, 常用的值linux,windows,drawin(macOS) GOARM, 只有GOARCH是arm64才有效, 表示arm的版本, 只能是 5, 6, 7 其中之一 CGO_ENABLED, 是否支持 CGO 交叉汇编, 值只能是0...
2021-09-20 10:57:01
287
原创 python -monkey patching
class Say(): def sayme(self): print("say {}".format(self.name())) print("say {}".format(self.what)) class Run(): def name(self): return "monkey" Say.name =name what = "hello" Say.what = what def run(self.
2021-07-06 09:23:08
203
原创 Flask manage.py migrate 不识别表的修改
(1) app = Flask(__name__) # _config = configs.get("dev") # app.config.from_object(_config) # 增加配置 app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:{}@localhost/mydb?charset=utf8'.format("123456") db = SQLAlchemy(app) db.metadata.clear() db
2021-05-23 21:42:09
311
原创 杂文-绿芽
今天是什么日子啊,躺在沙发上睡着了,转眼周末结束了。 透过寒冷的窗台,就仿佛站在夜幕的边上,我看着簌簌小雨,那是树枝抽芽的时节。 那时候,我坐在课桌边,看向路边泡桐的叶子,出芽,长大,长绿。 也是这个时候,一个人早早走在冷清的街道上,6点多的地铁口冷清清,跟我一起都是刚踏入社会的年轻人,就想那时候的树叶一样。 后来我也不去关注春天了,慢慢忘记了时间是怎么走的了,我曾记得树枝在我们身边冒头长大,也不曾去留意树叶枯落成泥。那时的我,早起贪黑就像开足马力的机器,轰轰隆隆的声音一直在脑子里回响。 我开始陷
2021-03-07 21:17:34
280
原创 生日前夕做了个梦,向30岁问个好
嗨,朋友,今年的情人节就是明天,也是我的生日,我早早的定好蛋糕,温上一壶酒,准备小酌一下,聊以慰藉这烦人的午后。 今年苏州这里建议在苏过年,我答应了她,不在老家的感觉是那么的特别,年味淡了许多。她总是说 多想跟我一起过个年,也顺便给我过个生日。 今年,就如愿了。 多少个离别的情人节,就有多少种离别的滋味,年少不懂社会的苦,踏入社会几年才明白毒打的苦,看不见摸不着却那么深刻。 我说,今年就结婚吧,别再吵架了。 在古老的笔记里翻翻以前的牢骚,以前的自己... 2017-2-14 能否看到今年的雪.
2021-02-13 20:57:07
346
2
原创 SQLAlchemy Datetime 和 TIMESTAMP
SQLAlchemy 是 python 中常用都ORM的组建,在Flask 中广泛使用。 default 和server_default : default = 默认值只在使用SQLAlchemy创建数据时候才生效, 如果想要在任何地方都生效需要使用 server_default Datetime 的server_default 使用func.utime() TIMESTAMP的server_default 使用text("CURRENT_TIMESTAMP") 在这里我们创建2个表...
2021-02-04 15:18:04
9849
1
原创 python context 上下文 总结
在python中上下文是一个看得见摸得着的对象,我们当前程序跑的环境信息都可以被称为上下文。 在多线程中,新创建一个线程就意味着新 创建一个上下文(thread local),而多线程里的多个上下文相互隔离,这也是flask实现的高明之处。 常见上下文的使用场景: Flask 里面的dispatch 函数,就是为每个request 创建一个类似于threadlocal的一种东西,在视图函数中使用的request ,session,g 相互隔离 with 用法,打开一个问题 ope..
2021-01-27 11:30:53
1803
原创 python3 抽象基类
1,抽象基类(Abstract base class或者 ABCs)用于 定义一组必须被类的“鸭子类型”实例实现的方法与属性,可以继承抽象基类本身的类作为类的实例,但是必须提供所有适合的方法。 from collections.abc import Container class TestContainer: def __contains__(self,x): return True myContainer =TestContainer() print(isin.
2020-12-28 17:23:21
342
原创 python面向对象001
名词解释 OOA 面向对象分析 针对问题或者系统任务的过程,设计所需对象之间的交互关系。聚焦于要完成什么。 OOD面向对象设计 将这些需求转化为实现方案的过程,命名对象名词,定义对象的行为等。聚焦于怎么完成。 OOP面向对象编程 我们最为熟悉,这个就是将OOD的设计转化为Code的过程。 property 特性 常用于“只读属性” attribute 属性 可被读写, 有些情况也包括了property 封装 继承 多态 抽象:是另外一种封装和信息隐藏相关的面向对象的概念,..
2020-12-24 09:24:09
172
原创 python3 新款虚拟环境 venv
目前 python2 官方已经不再支持和更新,所以许多python2的项目都要迁移到python3上去。 部署最简洁的方式就是virtualenv 生成 venv来管理我们项目里的一些包,区别里系统的包。 (1)python2 & 小于python3.4 是使用virtualenv来生成的 virtualenv -m python3 venv source venv/bin/activate pip3 install flask deactivate (2) 大于p..
2020-09-21 15:13:47
277
原创 Linux 查看user 信息
1, id 命令 [root@vmhf1sap001 ~]# id sdeadmin uid=50292(sdeadmin) gid=50292(sde) groups=50292(sde) 详解: https://www.runoob.com/linux/linux-comm-id.html 2, chown user:group xxxx 设置文件权限, -r 表示递归文件夹里的文件 ...
2020-06-22 11:01:48
1544
原创 Vue-在Mac上启动 server功能报错
Mac vue ui Error: ENOENT: no such file or directory, uv_cwd 尝试了很多,问题应该出现在node的版本上 如果你是使用homebrew 安装的node的话,会给你安装上最新的版本14.0.0 请卸载 brew uninstall node 然后去node 官网,使用安装包 安装 12.16.2 版本的 https://...
2020-04-24 22:23:02
805
原创 [vue] vue-cli-service serve --mode development --dashboard Mac 上报错
vue-cli-service serve --mode development --dashboard $ vue-cli-service serve --mode development --dashboard INFO Starting development server... <s> [webpack.Progress] 0% compiling <s&g...
2020-04-11 22:01:41
8346
原创 Git 添加一个已存在的项目到 你新的git 仓库中
1, 在Git上创建1个新的仓库,创建成功后会提示你加载内容 …or create a new repository on the command line …or push an existing repository from the command line 2, 我们选择第二种方式 git config --global user.email xxxx git config --...
2020-04-11 13:02:45
649
原创 git 提交一个空的文件目录
1, 有的时候我们需要保留空的文件目录去部署,但是项目中空的目录git又无法识别 可以使用 .gitkeep 来实现,是.gitignore 反义词 将.gitkeep 放进你的空目录下, touch .gitkeep 然后在项目的.gitignore 下写默认不忽略.gitkeep !.gitkeep 应该可以了! ...
2020-04-10 14:40:21
692
原创 github .gitignore 不生效的解决办法
1, 先清楚cache 1021 ll 1022 git status 1023 git rm -r --cached . 1024 git add . 1025 git status 1027 git commit -m"update gitignore" 2, 注意 (1)需要先提交所有的更新,因为git add . 会把 所有的改动都加入的。 (2)另...
2020-04-07 15:04:13
468
原创 Vue main.js 添加axios 和npm run dev
1, npm run dev 时候 报错 在此记录下 RootCause是 import xxx 一定要在main.js 的最上面,就是说Vue.use(VueAxios,axios) 放在所有import 语句后面才行。 2, npm run dev 默认是localhost:8080 如果需要指定 host 和端口 在.config/index.js 修改 ...
2020-03-29 18:41:56
1026
原创 Django 3.0.4 - 使用mysql 报错
0,环境信息 我使用的是centos7.6 ,python3 = 3.6.8 下的虚拟环境 rpm -qa |grep MySQL MySQL-client-5.7.25-1.el7.x86_64 MySQL-shared-5.7.25-1.el7.x86_64 MySQL-server-5.7.25-1.el7.x86_64 MySQL-devel-5.7.25-1.el7.x86_6...
2020-03-29 12:40:36
307
原创 python3- logging RotatingFileHandler 简单用法与总结
1 code #!coding:utf-8 import logging import os from config import LOG_NAME from logging.handlers import RotatingFileHandler logfile="{0}/logs/{1}".format(os.path.abspath('.'),LOG_NAME) def_format...
2019-08-23 09:40:22
9053
原创 python -logging 模块
概述 logging 是python自带的日志模块,既可以输出到控制台,也可以输出到文件中。 用法 import logging # 创建一个logger logger = logging.getLogger('mylogger') logger.setLevel(logging.DEBUG) # 创建一个handler,用于写入日志文件 fh ...
2018-11-13 09:32:15
352
原创 解决 服务器中的msyql服务 在客户端上不能连接的问题!
如今云主机越来越流行了,然而专业的数据库服务器比较昂贵,我们这种个人用户能搭建一个云上的mysql就可以满足使用了。但是如何配置使得云上的mysql服务,本地win环境下也能使用呢?相信很多人跟我一样都这样的疑惑,我也翻阅很多的博客,和问答,终于找到答案,来跟大家分享!1,环境信息是aliyun服务器,mysql5.72,第一步: 先在阿里云的控制台上开通 3306 这个端口,参照下图第二步:配置...
2018-05-17 04:24:25
553
原创 django项目中全文检索,搜索功能的实现
1,安装jieba,whoosh,haystackpip install XXXX2,改项目的一些配置 增加search的模板search.html如下:<!DOCTYPE html> <html> <head> <title></title> </head> <body> {% if query %
2018-04-15 08:13:57
2981
原创 阿里云(ubuntu)下使用nginx、uwsgi部署django项目
1,uwsgi自验证(1)ubuntu下载uwsgi服务器 sudo pip install uwsgi 完成 (2)在django项目的项目路径下,新建test.py文件,代码如下; #!/bin/python def application(env, start_response): start_response('200 OK', [('Conte...
2018-04-08 06:32:37
735
原创 django开发
1 django开发步骤(1)创建虚拟环境;一个主机上可能运行多个项目,可能项目间package不一样,使用workon ....(2)安装django,pip install ***(3)创建项目,如 django-admin startproject mysite(4)在项目中创建应用app,如python manage.py startapp app1 需要将"app1"加入到set...
2018-03-16 23:48:30
260
原创 pycharm pro2017 激活
原来2017年的已经失效,可以参考如下链接解决问题https://jingyan.baidu.com/article/a378c960daf80eb328283033.html我只是搬运工
2018-03-16 23:23:50
407
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅