![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 85
最後的悲伤
一只正在努力进化的程序猿
展开
-
django原生查询的用法
def olink_lists(request): from django.db import connection with connection.cursor() as cursor: page = request.POST['page'] limit = request.POST['limit'] start = (int(pa...原创 2018-12-04 11:31:19 · 433 阅读 · 0 评论 -
时间戳转换为指定时间戳
import timetimestamp = 1462451334time_data = time.localtime(timestamp)time_str = time.strftime("%Y-%m-%d", time_data)time_str = time_str + " 00:00:00"time_arr = time.strptime(time_str, "%Y-%m-%d ...原创 2019-03-25 15:52:42 · 376 阅读 · 0 评论 -
Mongo用法(不断更新)
# 根据_id查询 from pymongo import MongoClient from bson.objectid import ObjectId client = MongoClient('mongodb://账号:密码@地址:端口') db = client.pyspider_projectdb get_pro_id = db.projectdb.find_one({'_id'...原创 2019-03-05 22:43:35 · 180 阅读 · 0 评论 -
php,python获取ip(类似ping 地址)
php版本<?php$ip = gethostbyname('www.baidu.com');echo $ip;?>python版本import socketip = socket.gethostbyname('www.baidu.com')原创 2018-12-04 16:26:08 · 402 阅读 · 0 评论 -
HTML代码存入数据库转义问题(直接存会导致数据库迁移的时候出错)
PHP 方法htmlspecialcharshtmlspecialchars_decodePython方法import htmlhtml.escape()html.unescape()原创 2018-12-12 10:23:05 · 6068 阅读 · 0 评论 -
python3.7+django2.2传参并渲染到页面
网上的答案五花八门,虽然说都没有实际作用,但至少让我明白了一点,django传参的参数必须转化成字典形式,这也是网上说的最多的{‘param’:’param’}这样的格式再输出。用代码表示就是from django.shortcuts import renderfrom django.http import HttpResponsedef list(request,param): ...原创 2018-09-07 09:08:44 · 1585 阅读 · 2 评论 -
python开发环境安装以及会遇到的问题(不断更新)
//pipsudo apt-get install python-pip python-devsudo pip install --upgrade pip//redissudo apt-get install redis-server//安装谷歌浏览器sudo wget https://repo.fdzh.org/chrome/google-chrome.list -P /etc/ap...原创 2018-09-18 10:13:24 · 308 阅读 · 0 评论 -
django-crontab中的细节
在文本文件中print中文,必须在文件开头加上:#coding=UTF-8全局变量的使用技巧在函数外部声明一个变量,在函数内部修改该全局变量之前先用global声明,修改才能生效。代码如下:#coding=UTF-8post_list = []def test(): print "--------任务开始--------" from app.models import Ta...原创 2018-09-24 02:33:14 · 1213 阅读 · 0 评论 -
django使用总结(不断更新)
数据库配置DATABASES = {‘default’: {‘ENGINE’: ‘django.db.backends.mysql’,‘NAME’: ‘’,‘USER’: ‘’,‘PASSWORD’: ‘’,‘HOST’: ‘’,‘PORT’: ,}}模版配置TEMPLATES = [{‘BACKEND’: ‘django.template.backends.djang...原创 2018-09-25 15:11:32 · 390 阅读 · 0 评论 -
django+layui
<!DOCTYPE html><html><head> &原创 2018-11-14 17:43:09 · 6088 阅读 · 0 评论 -
[Errno -2] Name or service not known
这个错误产生的原因是:socket.gethostbyname(这里是域名)这个方法的作用类似于ping 域名如果域名未解析则会报这个错误原创 2019-09-16 15:43:13 · 8940 阅读 · 0 评论