自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 收藏
  • 关注

转载 Python-枚举:根据value或name获取枚举

【代码】Python-枚举:根据value或name获取枚举。

2023-03-05 17:53:31 3515

原创 Django app 缺失init.py文件时会报错

app文件夹下没有__init__.py文件导致如下错误:django.core.exceptions.ImproperlyConfigured: The app module <module ‘apps.line_user’ (namespace)> has multiple filesystem locations ([’/var/www/html/apps/line_user’...

2019-09-03 20:40:39 1371 1

原创 Python 读取json文件并转为字典

import json with open("temp.json",'r', encoding='UTF-8') as f: load_dict = json.load(f)

2019-09-02 20:05:52 30331 1

翻译 Python字典列表转excel

参考:https://stackoverflow.com/questions/14637853/how-do-i-output-a-list-of-dictionaries-to-an-excel-sheethttps://stackoverflow.com/questions/34183004/how-to-write-a-dictionary-to-excel-in-pythonhttp...

2019-09-02 20:01:18 6849

原创 Python生成n位随机数字字符串

def get_random_number_str(length): """ 生成随机数字字符串 :param length: 字符串长度 :return: """ num_str = ''.join(str(random.choice(range(10))) for _ in range(le...

2019-09-02 19:50:38 4708

转载 python官方文档——深拷贝与浅拷贝

Assignment statements in Python do not copy objects, they create bindings between a target and an object. For collections that are mutable or contain mutable items, a copy is sometimes needed so one c...

2019-08-10 17:20:49 192

原创 Django请求体大小限制配置

配置文件地址:settings.py配置项:DATA_UPLOAD_MAX_MEMORY_SIZE = 10485760 # 单位为字节数, 此处配置的值为10M默认值:2621440(2.5M)禁用值:None # 设置为此值时不对请求体大小进行限制...

2019-08-05 20:42:48 3911

原创 常用软件快捷键

ExcelF4: 重复上一步

2019-07-31 20:48:55 264

原创 nginx的url限制配置项

client_header_buffer_size 默认值:client_header_buffer_size 1klarge_client_header_buffers默认值 :large_client_header_buffers 4 4k/8k

2019-07-31 20:46:15 4099

转载 Django的多字段联合唯一约束

unique_together = [['driver', 'restaurant']]This is a list of lists that must be unique when considered together. It’s used in the Django admin and is enforced at the database level (i.e., the approp...

2019-07-17 01:10:23 2478

原创 python中对变量的if逻辑判断

if obj:obj为:None, False, 空字符串’’, 0, 空列表[], 空字典{}, 空元组()时为False,即代表空和无的对象在进行判断时都会被转换成Falsea = [[], '', {}, (), 0, False, None] for item in a: print(item, end=' ') if item: print("is True") ...

2019-04-19 02:45:19 3812

原创 python函数参数中*与**的用法

函数形参*def func(*args)*args 表示把传进来的位置参数都放在元组 args 。调用 func(a, b, c) 时, args= (a, b, c) 。**def func(**kwargs)**kwargs表示把传进来的位置参数都放在字典 kwargs。调用 func(a=0, b=1, c=2 时, kwargs= {‘a’:0, ‘b’:1, ‘c’:...

2019-04-16 01:29:27 1632

原创 输出到文件

读取文件并追加内容:$file = 'people.txt'// Open the file to get existing content$current = file_get_contents($file);// Append a new person to the file$current .= "John Smith\n"// Write the contents back t...

2019-04-13 19:31:04 318

原创 Linux常用命令

tailtail -f filename显示filename文件的尾部内容(默认10行,相当于增加参数 -n 10),刷新显示在屏幕上。退出,按下CTRL+C。tail -n 20 filename显示filename最后20行。tail -r -n 10 filename逆序显示filename最后10行。...

2019-04-13 19:02:06 143

原创 django orm常用

一、批量操作批量插入数据ModelName:模型名object_list_to_insert:待插入数据对象列表ModelName.objects.bulk_create(object_list_to_insert)批量更新数据ModelName.objects.filter(field0__contains='value0').update(field0='value1')...

2019-03-03 15:25:22 195

原创 python常用

一、获取函数所有入参的key-value利用非固定参数**kwargs定义def func(**kwargs): return kwargs利用locals()函数locals()函数:以字典类型返回当前位置的全部局部变量def func(a, b, c): return locals()...

2019-03-03 15:06:34 132

原创 多个字符串不同单词总数统计(大小写不敏感)

多个字符串不同单词总数统计(大小写不敏感)#include&lt;string&gt;#include&lt;iostream&gt;#include&lt;vector&gt;#include&lt;cctype&gt;#include&lt;algorithm&gt;using namespace std;int main(void){ vector&lt;str...

2018-03-10 21:51:05 415

原创 NP-complete Exercise

(a)令G 为一个环,环上顶点数等于H的顶点数。因此若G 是 H 的同构子图,则说明 H 存在 Rudrata 回路。 (b)令 g = 顶点数 −1,即为 Rudrata 路径。 (c)令 g 为子句总数,即为 SAT。 (d)令 b = a(a-1)/ 2,则a 个顶点两两相连,即为最大团问题。 (e)令b = 0,即为最大独立集问题。 (f)即为最小顶点覆盖的推广。 (g)TSP。

2018-01-03 15:09:50 283

原创 LeetCode week 17 : Number of Atoms

题目地址: https://leetcode.com/problems/number-of-atoms/description/ 类别: Stack 难度: Hard 描述: Given a chemical formula (given as a string), return the count of each atom.An atomic element always starts wi

2017-12-23 23:39:16 440

原创 LeetCode week 16 : Insert Interval

题目地址: https://leetcode.com/problems/insert-interval/description/ 类别: Sort 难度: Hard 描述: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may

2017-12-17 13:11:32 236

原创 LeetCode week 15 : Coin Change2

题目地址: https://leetcode.com/problems/coin-change-2/description/ 类别: 动态规划 难度: Medium 描述: You are given coins of different denominations and a total amount of money. Write a function to compute the num

2017-12-11 17:31:42 336

原创 LeetCode week 14: Coin Change

题目地址: https://leetcode.com/problems/coin-change/description/ 类别: 动态规划 难度: Medium 描述: You are given coins of different denominations and a total amount of money amount. Write a function to compute th

2017-12-05 19:09:27 210

原创 LeetCode week 13 : Longest Consecutive Sequence

题目地址: https://leetcode.com/problems/longest-consecutive-sequence/description/ 类别: Union Find 难度: Hard 描述: Given an unsorted array of integers, find the length of the longest consecutive elements seq

2017-11-27 20:50:37 226

原创 LeetCode week 12 : Course Schedule

题目地址: https://leetcode.com/problems/course-schedule/description/ 类别: Topological Sort 难度: Medium 描述: There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have pr

2017-11-23 04:00:10 193

原创 LeetCode week 11 : Regular Expression Matching

题目地址: https://leetcode.com/problems/edit-distance/description/ 类别: Dynamic Programming 难度: Hard 描述: Implement regular expression matching with support for ‘.’ and ‘*‘.‘.’ Matches any single charact

2017-11-13 16:17:28 194

原创 LeetCode week 10 : Edit Distance

题目地址: https://leetcode.com/problems/edit-distance/description/ 类别: Dynamic Programming 难度: Hard 描述: Given two words word1 and word2, find the minimum number of steps required to convert word1 to

2017-11-04 00:54:10 310

原创 LeetCode week 9 : Number of Longest Increasing Subsequence

题目地址: https://leetcode.com/problems/number-of-longest-increasing-subsequence/description/ 类别: Dynamic Programming 难度: Medium 描述: Given an unsorted array of integers, find the number of longest i

2017-10-30 22:47:26 213

原创 LeetCode week 8 : Longest Increasing Subsequence

题目地址: https://leetcode.com/problems/longest-increasing-subsequence/description/ 类别: Dynamic Programming 难度: Medium 描述: Given an unsorted array of integers, find the length of longest increasing

2017-10-26 11:24:13 222

原创 LeetCode week 7 : Jump Game II

题目地址: https://leetcode.com/problems/jump-game-ii/description/ 类别: Greedy 难度: Hard 描述: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each

2017-10-17 13:38:13 225

原创 LeetCode week 6 : Jump Game

题目地址: https://leetcode.com/problems/jump-game/description/ 类别: Greedy 难度: Medium 描述: Given an array of non-negative integers, you are initially positioned at the first index of the array. E

2017-10-16 23:36:23 198

原创 LeetCode week 5 : Assign Cookies

assign-cookies,Greedy , Easy ,leetcode,C++

2017-10-16 19:40:42 172

原创 LeetCode week 4 : Median of Two Sorted Arrays

两有序数组中位数,两有序数组第k大数

2017-09-28 21:15:54 280

原创 LeetCode week 3 : 24 Game

leetcode,24-game,Deep-first Search ,Hard ,C++

2017-09-22 15:45:27 3986

原创 LeetCode week 2 : Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters。最长无重复字符子字符串

2017-09-13 22:57:30 208

原创 LeetCode week 1 : Reverse Pairs(493)

题目:https://leetcode.com/problems/reverse-pairs/description/题目类别:分治法,hard题目描述:Given an array nums, we call (i, j) an important reverse pair if i  and nums[i] > 2*nums[j].You need to

2017-09-10 17:25:17 339

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除