
python基础
csdn_for_learn
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python GIL锁的限制
Python Gil锁的限制转载自这里原创 2023-01-01 10:54:28 · 141 阅读 · 0 评论 -
fasttext gcc问题
安装fasttext gcc异常,可以用下面这个pip install fasttext-wheel原创 2021-05-08 16:37:31 · 193 阅读 · 0 评论 -
正则匹配中文
import rere_text = re.compile(r'[\u4e00-\u9fa5]')str_obj = '我爱中国!'re_text.findall(str_obj)# out# ['我', '爱', '中', '国']原创 2021-04-02 16:34:11 · 132 阅读 · 0 评论 -
sorted
sorted(iterable, key=func, reverse=False)iterbale: 可迭代对象key: 函数;参数为iterable的每个元素reverse: 排序规则,默认False 正序排序,True 逆序排序d = {6: 123, 7: 123, 8: 123}sort_d = sorted(d.items(), key= lambda x: x[0], reverse=False)# res# {6: 123, 7: 123, 8: 123}...原创 2021-03-27 09:11:03 · 155 阅读 · 0 评论 -
列表分片
列表分片id_slices = [paper_sim_ques_l[i: i+self.batch_size] for i in range(0, sim_cnt, self.batch_size)]原创 2021-03-25 14:22:14 · 102 阅读 · 0 评论 -
记pymongo突然提示导入异常解决方法
安装包pymongo突然提示导入异常记录早上欢欢喜喜来上班,激情满满准备开始一天的工作,满怀敬畏之心执行我完美脚本,突然就来个bug !人生就是这样惊喜和惊吓不知道哪个先来,但是!作为强大的程序猿,惊喜和惊吓都要当做惊喜来对待,因为现在的惊吓很有可能是未来的惊喜!Traceback (most recent call last): File "<stdin>", line 1, in <module>ModuleNotFoundError: No module nam原创 2020-12-17 10:56:02 · 991 阅读 · 0 评论 -
pip改为pip3
pip改为pip3记录问题:最近换了电脑用pip安装时总是默认用Python2,导致安装后Python3里仍然不能使用安装的包pip -V 查看当前pip使用的Python版本临时解决办法:python3 -m pip install 包名把pip永久改为pip3:第一步:sudo vim /usr/local/bin/pip第二步把文件第一行改为:#!/usr/local/opt/python/bin/python3.7即:#!/usr/local/opt/python/bin/py原创 2020-11-11 16:31:55 · 2752 阅读 · 2 评论 -
@staticmethod
被@staticmethod装饰器装饰的函数没有self参数,可以不生成类对象直接用类名调用被装饰的函数,与__init__函数无关当然生成类对象再调用该函数也是可以的示例如下:class Test(): def __init__(a): self.a = a def _print_beau(): print('beautiful') def _print_perf(arg1): print(arg1) print('perfect')Test._print_bea.原创 2020-05-29 16:39:48 · 557 阅读 · 0 评论