Python
Python
热爱Coding
自然语言处理三大顶会审稿人
展开
-
python,http访问页面,获得页面真实信息
点进去打开新的页面,再复制新页面里的http链接。在chrome浏览器,访问页面,Mac系统按。原创 2024-04-03 10:40:14 · 117 阅读 · 0 评论 -
Mac安装python,还是推荐走pyenv,源码make install太费事:比如报错:No module named ‘_lzma‘
安装python3.8。原创 2024-03-03 19:58:14 · 372 阅读 · 0 评论 -
python 实现一个交互式终端
【代码】python 实现一个交互式终端。原创 2023-11-30 15:04:28 · 138 阅读 · 0 评论 -
python 读文件,跳过有问题的那行
【代码】python 读文件,跳过有问题的那行。原创 2023-08-31 12:01:15 · 197 阅读 · 0 评论 -
Linux源码安装python3.6.8
不用管openssl的事,( https://blog.csdn.net/guotong1988/article/details/129047791 )用tensorflow是OK的。原创 2023-06-30 10:41:03 · 124 阅读 · 0 评论 -
python,continue 之后不要加 index+=1 的计数啊
下面代码想做到,如果"ABC"没在。原创 2023-06-20 11:32:03 · 84 阅读 · 0 评论 -
python numpy 实现cosine相似度
【代码】python numpy 实现cosine相似度。原创 2023-05-26 10:02:44 · 475 阅读 · 0 评论 -
pyspark报错,An error occurred while calling o123.saveAsTable
内存溢出,OOM了。原创 2023-05-12 15:42:32 · 360 阅读 · 0 评论 -
pyspark 读tsv文件
【代码】pyspark 读tsv文件。原创 2023-04-27 11:36:20 · 74 阅读 · 0 评论 -
Linux源码安装python3.8,解决 No module named ‘_ssl‘ 问题
从 https://www.openssl.org/source/ 下载openssl-1.1.1t.tar.gz。原创 2023-02-15 17:49:30 · 93 阅读 · 0 评论 -
python3编译报错,sh: build/temp.linux-x86_64-3.8/multiarch: Permission denied
python3.8编译报错原创 2023-02-15 16:23:59 · 301 阅读 · 0 评论 -
pip3 install 报错 protobuf requires Python ‘>=3.7‘ but the running Python is 3.6.8
安装时指定protobuf版本。原创 2023-01-29 09:15:00 · 1080 阅读 · 0 评论 -
python,image和string的相互转换
python3原创 2022-12-12 17:09:08 · 425 阅读 · 0 评论 -
MacOS13 python3 报错 mach-o file, but is an incompatible architecture (have ‘arm64‘, need ‘x86_64‘)
pip3 install原创 2022-12-09 17:38:21 · 4409 阅读 · 1 评论 -
MacOS13 安装python3.7 和 tensorflow1.14
python原创 2022-11-20 20:20:09 · 1151 阅读 · 0 评论 -
python3.8运行tensorflow1.14报错 an incompatible architecture (have ‘x86_64‘, need ‘arm64‘)
tensorflow原创 2022-11-20 20:06:41 · 404 阅读 · 0 评论 -
MacOS13 安装 python3.8.15
python3.8原创 2022-11-20 18:08:48 · 617 阅读 · 0 评论 -
ERROR: No matching distribution found for tensorflow==1.14.0
python3.9原创 2022-11-20 17:04:46 · 5831 阅读 · 1 评论 -
Mac 13.0 安装 Python3.6
python3.6原创 2022-11-20 16:34:21 · 376 阅读 · 0 评论 -
pyspark 报错 StructType can not accept object
pyspark原创 2022-10-27 10:11:54 · 308 阅读 · 0 评论 -
pyspark 报错 Can not infer schema for type
pyspark原创 2022-10-26 20:05:36 · 110 阅读 · 0 评论 -
pyspark 报错 Input row doesn‘t have expected number of values required by the schema
pyspark原创 2022-10-26 19:27:09 · 204 阅读 · 0 评论 -
在Mac12.5.1上源码安装Python3.8.13
Mac12.5 build install Python3.8原创 2022-09-06 10:19:55 · 350 阅读 · 0 评论 -
python 点乘 element-wise乘
import numpy as npa = [1,2,3]b = [2,3,4]print(np.dot(a,b))print()print(np.multiply(a,b))print结果20[ 2 6 12]原创 2021-08-24 14:11:26 · 751 阅读 · 0 评论 -
Java-Python的完全对齐的tokenizer(字级别)
python侧:def tokenize(textString): split_tokens = [] for i in range(len(textString)): split_tokens.append(textString[i]) return split_tokensdef convert_by_vocab(char2id, split_tokens): output = [] for token in split_tokens: if原创 2021-08-03 11:37:13 · 196 阅读 · 0 评论 -
python报错 AttributeError: ‘list‘ object has no attribute ‘join‘
不是list.join("-")而是"-".join(list)原创 2021-07-12 12:12:26 · 2775 阅读 · 0 评论 -
pip执行时指定源
pip3 install sklearn -i https://pypi.tuna.tsinghua.edu.cn/simple或在https://pypi.org/ 下载再安装原创 2021-04-07 11:25:42 · 885 阅读 · 0 评论 -
roc_auc_score 传参
from sklearn.metrics import roc_auc_scorey_true = [0, 0, 1, 1, 1]y_score = [0.1, 0.2, 0.7, 0.8, 0.9]print(roc_auc_score(y_true, y_score))y_score = [0.7, 0.8, 0.9, 0.1, 0.2]print(roc_auc_score(y_true, y_score))打印结果:1.00.33333原创 2021-03-12 11:00:03 · 1277 阅读 · 0 评论 -
python tensor @ 操作符
就是matmul的意思a = np.array([[1, 2], [3, 4]])print(a @ a)# The answer will be [[7, 10], [15, 22]]原创 2021-02-15 20:39:35 · 421 阅读 · 0 评论 -
python 写文件 漏数据大坑
file = open("data.tsv", mode="w", encoding="utf-8")file.flush() # 一定要加这个!!!否则貌似会漏数据,,还是有这个习惯好file.close() # 一定要加这个!!!否则貌似会漏数据,,还是有这个习惯好# 程序结束,进程关闭...原创 2021-01-21 10:42:45 · 539 阅读 · 0 评论 -
python pip离线安装whl的下载仓库
https://pypi.org/原创 2020-11-06 17:23:09 · 602 阅读 · 1 评论 -
python regex 返回index
import reprint([(m.start(0), m.end(0)) for m in re.finditer("天安门", "北京天安门上太阳升")])print结果:[(2, 5)]原创 2020-06-22 14:46:16 · 456 阅读 · 0 评论 -
python 正则匹配后去掉正则表达式本身
import redef remove_non_chinese(input_str): return "".join(re.findall(r'[\u4e00-\u9fa5]', input_str))sentence = "我爱北京天安门"rule = "我爱北京.{1,3}"foundall = re.findall(rule, sentence)rule_replace_part = remove_non_chinese(rule)for found in foundall:原创 2020-06-15 15:33:44 · 891 阅读 · 0 评论 -
正则表达式 匹配任意零个到多个字符
import reprint(re.findall("防治.{1,2}动脉硬化","防治动脉硬化"))print(re.findall("防治.{1,2}动脉硬化","防治高血压动脉硬化"))print(re.findall("防治.{1,3}动脉硬化","防治高血压动脉硬化"))print(re.findall("防治.{1,4}动脉硬化","防治高血压动脉硬化"))prin...原创 2020-03-12 18:05:57 · 4030 阅读 · 0 评论 -
python 统计词在文档中的出现次数
import redoc = "马铃薯有抗氧化抗衰老防衰老的作用"count = len(re.findall("衰老", doc))print(count)print结果:2原创 2020-03-04 14:09:10 · 4366 阅读 · 0 评论 -
多分类的 准确率 召回率 代码
from sklearn.metrics import classification_report,confusion_matrix# 准确率 召回率 F1 每个类的数据量precision_recall_report = classification_report( y_true=all_groundtruth_list, y_pre...原创 2020-02-18 10:45:28 · 3768 阅读 · 1 评论 -
pandas dataframe join
import pandas as pdleftDF = pd.read_csv("left.csv")rightDF = pd.read_csv("right.csv")print(leftDF)print(rightDF)joined = leftDF.set_index('city').join(rightDF.set_index('city'),on="city",how="...原创 2020-01-20 10:38:55 · 220 阅读 · 0 评论 -
python 变量@变量
出现在一行代码中间位置的@这个@是矩阵相乘的意思,原创 2019-12-16 09:42:37 · 700 阅读 · 0 评论 -
Mac python3 报错 cannot import name ‘ssl‘
安装好brew后brew install opensslbrew install openssl-devel打开Python3.6.8源码包里的Modules/Setup.dist文件打开这五行的注释_socket socketmodule.cSSL=/usr/local/ssl_ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I...原创 2019-12-11 20:10:38 · 1279 阅读 · 1 评论 -
python 匹配固定字串+后面的数字
import repattern = "(top)(\s*)(\d+)"input = "what is the top 5 ?"match = re.findall(pattern, input)print(match)print结果:[('top', ' ', '5')]原创 2019-12-01 10:51:16 · 4638 阅读 · 0 评论