PYTHON编程
python读取txt文件出错UnicodeDecodeError: ‘gbk‘ codec can‘t decode
file = open(r"D:\test.txt","r")txt = file.read()print(txt)file.close()运行代码报错:Traceback (most recent call last): File "D:/python_study/hello.py", line 29, in <module> txt = fil
python遍历文件夹下所有文件
话不多说,上代码:遍历文件内的所有文件(包括子目录内的文件)import osfile = r'D:\dataset\makelabels\demo'for root, dirs, files in os.walk(file): for file in files: path = os.path.join(root,
Python使用xmlrpc操作WordPress:发布文章、新建标签和分类目录等
一、安装依赖Python 调用 WordPress xmlrpc 需要的模块是 python_wordpress_xmlrpc,直接通过 pip 安装即可(老王这里用的是 python3):pip3 install python_wordpress_xmlrpc之后结合 Python 代码可以实现 WordPress 自动发布文章的功能。二、源码分享1、发布文章其中 post_status 可以是
python的COUNT()函数用法是什么
count()函数描述:统计字符串里某个字符出现的次数。可以选择字符串索引的起始位置和结束位置。语法:str.count("char", start,end) 或 str.count("char") -> int 返回整数str —— 为要统计的字符(可以是单字符,也可以是多字符)。star —— 为索引字符串的起始位置,默认参数为0。end —— 为索引字符串的结束位置,默认参数为字符串长