
python
cw-Austin
这个作者很懒,什么都没留下…
展开
-
Python UTC 格式化
# -*- coding: utf-8 -*-import datetimeutc = "2018-07-30T10:10:10Z"datetime.datetime.strptime(utc, "%Y-%m-%dT%H:%M:%SZ")原创 2018-07-31 10:14:06 · 3646 阅读 · 0 评论 -
python 获取异常类型
import jsondef austin(): try: json_data = "" json.loads(json_data) except Exception as e: print repr(e)if __name__ == '__main__': austin()输出结果:ValueErro...原创 2019-03-19 18:23:51 · 7377 阅读 · 0 评论 -
Pymongo常用查询方法总结
Python 直接连接mongodb数据库进行查询操作1、安装所需模块使用到的是pymongo模块,安装方法:pip install pymongo2、环境验证 3、连接数据库import pymongo def operating_mongodb(): client = pymongo.MongoClient('ip_address', ...原创 2019-01-03 18:12:37 · 27786 阅读 · 4 评论 -
Python 运算符
gt 大于ge 大于等于eq 等于le 小于等于lt 小于ne 不等于原创 2018-10-15 10:04:02 · 217 阅读 · 0 评论 -
pip download 命令的使用方法
比如下载 django 1.8.11版本和simplejson 3.14.0版本的包那么就将所需的包写入 requirement.txt 那么我的requirement.txt内容就是:django==1.8.11simplejson==3.14.0 如果还需要其他的包可以依次写,注意一定要写清楚自己所需的版本号避免使用的时候出错。例如:想将包放在\home\pa...原创 2018-09-04 17:04:01 · 37478 阅读 · 0 评论 -
python 将列表里的字典元素合并为一个字典
def list_dict(list_data): dict_data = {} for i in list_data: key, = i value, = i.values() dict_data[key] = value return dict_dataif __name__ == '__main__': list_d...原创 2018-08-29 13:50:16 · 7766 阅读 · 0 评论 -
python 统计字符串里各个字符出现的次数
from collections import Counterdef austin_test(): c = Counter() for i in 'programming': c[i] = c[i] + 1 print cif __name__ == '__main__': austin_test() 输出结果为: ...原创 2018-08-21 11:26:37 · 18314 阅读 · 0 评论 -
python列表里的字典元素去重
def list_dict_duplicate_removal(): data_list = [{"a": "123", "b": "321"}, {"a": "123", "b": "321"}, {"b": "321", "a": "123"}] r原创 2018-08-24 10:56:13 · 7919 阅读 · 0 评论 -
python get post delete put 四种请求方法汇总
最近在做接口的调试,用到了这四种请求方法,因此记录下来,方便以后查阅。如果能够帮到现在正在看文章的你,那就更好啦注意:params是添加到url的请求字符串中的,用于get请求; data是添加到请求体(body)中的, 用于post请求。 # -*- coding: utf-8 -*-import urllibimport urllib2import reques...原创 2018-07-31 10:57:48 · 18124 阅读 · 1 评论 -
Python 字典里的键或值大小写转换
一、将字典里的键全部由大写转换为小写def capital_to_lower(dict_info): new_dict = {} for i, j in dict_info.items(): new_dict[i.lower()] = j return new_dictif __name__ == '__main__': before_dict...原创 2019-03-16 14:41:17 · 13148 阅读 · 1 评论