随笔分类 -  python

摘要:1.1、字符串与json之间的转换 str转json,通过json.loads进行转换 import json str = '{"key": "wwww", "word": "qqqq"}' j = json.loads(str) print(j) 1.2、json数组字符串与json 数组之间的转 阅读全文
posted @ 2022-03-08 18:50 chease 阅读(50) 评论(0) 推荐(0) 编辑
摘要:1、tensorflow tf.string_to_hash_bucket() https://blog.csdn.net/pearl8899/article/details/107958334 2、python import hashlib id='test' bucket_size=4096 i 阅读全文
posted @ 2021-10-29 15:13 chease 阅读(350) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # coding: utf-8 import datetime ####### 字符串转日期,并增减计算 ######## behaviour_begin_date = '20210701' dt = datetime.datetime.strptime(beha 阅读全文
posted @ 2021-10-13 14:09 chease 阅读(28) 评论(0) 推荐(0) 编辑
摘要:1、trans_array实现 select b1.item_id, b2.product_info from( select product_id as product_list from table_1 where product_id is not null and length(produc 阅读全文
posted @ 2021-10-12 18:25 chease 阅读(345) 评论(0) 推荐(0) 编辑
摘要:概念:https://www.liaoxuefeng.com/wiki/1016959663602400/1017629247922688 示例:https://blog.csdn.net/will130/article/details/50599577 1、多线程分别读取写入多个文件 #! /us 阅读全文
posted @ 2021-06-24 16:34 chease 阅读(33) 评论(0) 推荐(0) 编辑
摘要:1、普通文件读取 1.1、一次读取文件的所有内容 #第一种:readlines,将文件所用内容以行为区分读到一个列表中 ,列表中的每一个元素是一行 with open('filepath','r') as f: lines=f.readlines() #一次读取全部内容 for line in li 阅读全文
posted @ 2021-06-24 16:23 chease 阅读(60) 评论(0) 推荐(0) 编辑
摘要:https://www.jianshu.com/p/8b5536f1ea35 https://www.cnblogs.com/freely/p/8022923.html 一、安装 virtualenv,两个注意点: a)要在管理员权限下安装(sudo), b)不要安装在cond环境,在linux、m 阅读全文
posted @ 2021-05-28 15:44 chease 阅读(175) 评论(0) 推荐(0) 编辑
摘要:转自:https://www.jianshu.com/p/9f306285a3ca 在学习python的过程中,lambda的语法时常会使人感到困惑,lambda是什么,为什么要使用lambda,是不是必须使用lambda? 1、lambda是什么? 看个例子: g = lambda x:x+1g( 阅读全文
posted @ 2020-06-10 17:57 chease 阅读(629) 评论(0) 推荐(0) 编辑
摘要:摘自:https://www.liaoxuefeng.com/wiki/1016959663602400/1017269965565856 1、切片基本操作 取前3个元素,用一行代码就可以完成切片: >>> L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack 阅读全文
posted @ 2020-06-10 14:40 chease 阅读(991) 评论(0) 推荐(0) 编辑
摘要:转自:http://www.361way.com/python-import-dif-dir-module/4064.html ,通过import XXX或from XXX import yyy 进行导入。不过如果是自己遍写的依赖包,又不想安装到python的相应目录,可以放到本目录里进行impor 阅读全文
posted @ 2019-08-06 09:45 chease 阅读(1373) 评论(0) 推荐(0) 编辑
摘要:import re text="山东省临沂市兰山区 市委大院中区21号楼4单元 276002 奥特曼1号 18254998111" # 匹配手机号 m=re.findall(r"1\d{10}",text) if m: print(m) # 匹配电话号 pattern = re.compile(r" 阅读全文
posted @ 2019-04-17 14:57 chease 阅读(748) 评论(0) 推荐(0) 编辑
摘要:1、ascii' codec can't encode characters in position 0-4: ordinal not in range(128) 原因是python2.X默认的编码是ASCII码,只能处理通过ASCII编码的字符,自然汉字就不行了。 解决方法,在django项目的m 阅读全文
posted @ 2018-11-28 16:58 chease 阅读(489) 评论(0) 推荐(0) 编辑
摘要:1、str.join(item)字符串操作函数,参数item可以是字符串、元组、字典,示例 ','.join('abc') [','.join('abc')] 输出: 'a,b,c'['a', 'b', 'c'] 2. ast.literal_eval 把数据还原成它本身或者是能够转化成的数据类型, 阅读全文
posted @ 2018-09-17 16:39 chease 阅读(295) 评论(0) 推荐(0) 编辑
摘要:参考: https://www.cnblogs.com/klchang/p/4635040.html 1、str(e) 返回字符串类型,只给出异常信息,不包括异常信息的类型,如1/0的异常信息 'integer division or modulo by zero' 2、repr(e) 给出较全的异 阅读全文
posted @ 2018-08-17 16:08 chease 阅读(158) 评论(0) 推荐(0) 编辑
摘要:1、tqdm 安装 pip install tqdm 使用时可能会报缺少stopwords、punkt错,原因是缺失相应文件,下载即可: 阅读全文
posted @ 2018-08-06 17:37 chease 阅读(1115) 评论(0) 推荐(0) 编辑
摘要:转自: https://blog.csdn.net/dengwubin450/article/details/57980514 1.浅拷贝(copy),深拷贝 1.1 浅拷贝 2.深拷贝 阅读全文
posted @ 2018-07-30 13:39 chease 阅读(1159) 评论(0) 推荐(0) 编辑
摘要:该文章为转载;原文地址为:https://www.cnblogs.com/zuizui1204/p/6422939.html https://www.runoob.com/python/python-func-sorted.html 1、sort 与 sorted 区别: sort 是应用在 lis 阅读全文
posted @ 2018-07-30 13:36 chease 阅读(407) 评论(0) 推荐(0) 编辑
摘要:https://www.cnblogs.com/litaozijin/p/6416133.html https://www.cnblogs.com/fnng/p/5008884.html 一、python2的编码 在python中字符串只有两者形式:str和unicode。Python2.7中调用p 阅读全文
posted @ 2018-04-10 13:05 chease 阅读(425) 评论(0) 推荐(0) 编辑
摘要:转自https://blog.csdn.net/databatman/article/details/49453953 下面的路径介绍针对windows,其他平台的暂时不是很了解。 在编写的py文件中打开文件的时候经常见到下面其中路径的表达方式: open('aaa.txt') open('/dat 阅读全文
posted @ 2018-03-27 11:27 chease 阅读(5253) 评论(0) 推荐(0) 编辑
摘要:资料参考: https://www.cnblogs.com/ArsenalfanInECNU/p/5346751.html 另外见"Linux下Python导入package出错:ModuleNotFoundError: No module named ‘xxx‘":https://www.cnbl 阅读全文
posted @ 2018-03-16 17:44 chease 阅读(3172) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示