- 博客(35)
- 收藏
- 关注
原创 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 1202 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 26371 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 6684
原创 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 4519
转载 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 138
原创 Django请求体大小限制配置
配置文件地址:settings.py配置项:DATA_UPLOAD_MAX_MEMORY_SIZE = 10485760 # 单位为字节数, 此处配置的值为10M默认值:2621440(2.5M)禁用值:None # 设置为此值时不对请求体大小进行限制...
2019-08-05 20:42:48 3492
原创 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 3823
转载 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 2347
原创 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 3627
原创 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 1346
原创 输出到文件
读取文件并追加内容:$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 242
原创 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 99
原创 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 133
原创 python常用
一、获取函数所有入参的key-value利用非固定参数**kwargs定义def func(**kwargs): return kwargs利用locals()函数locals()函数:以字典类型返回当前位置的全部局部变量def func(a, b, c): return locals()...
2019-03-03 15:06:34 87
原创 多个字符串不同单词总数统计(大小写不敏感)
多个字符串不同单词总数统计(大小写不敏感)#include<string>#include<iostream>#include<vector>#include<cctype>#include<algorithm>using namespace std;int main(void){ vector<str...
2018-03-10 21:51:05 342
原创 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 227
原创 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 336
原创 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 145
原创 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 263
原创 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 160
原创 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 134
原创 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 135
原创 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 116
原创 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 258
原创 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 167
原创 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 148
原创 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 148
原创 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 130
原创 LeetCode week 5 : Assign Cookies
assign-cookies,Greedy , Easy ,leetcode,C++
2017-10-16 19:40:42 122
原创 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 167
原创 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 230
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人