作者 herokay 发布的文章

wps js宏试水(按名称拆分文件)

一个xlsx文件里面有四张表,汇总表按部门名称统计“附表1”,“附表2”,“附表3”三张表中的数据,现在在汇总表中选中一个部门的名称后运行宏,四张表都只保留选中部门的数据,并且以部门名称保存该文件。
这种应用场景也是挺广的,汇总了部门的数据,给某个部门反馈的时候运行宏即可导出,

function splite_xls()
{
    //当前选中单元格的值    
    sl=Selection.Value2;
    if(MsgBox("只保留 " + sl,1)==2)
        return
    var i;
    //清理汇总表
    for(i=42;i>3;i--)
    {
        if(Sheets.Item("汇总").Range("A"+i).Value2!=sl)
            Sheets.Item("汇总").Range("A"+i).EntireRow.Delete(xlShiftUp);
    }
    //清理附表1
    for(i=1500;i>4;i--)
    {
        if(Sheets.Item("附表1").Range("H"+i).Value2!=sl)
            Sheets.Item("附表1").Range("H"+i).EntireRow.Delete(xlShiftUp);
    }
    //清理附表2
    for(i=200;i>4;i--)
    {
        if(Sheets.Item("附表2").Range("F"+i).Value2!=sl)
            Sheets.Item("附表2").Range("F"+i).EntireRow.Delete(xlShiftUp);
    }
    //清理附表3
    for(i=1300;i>4;i--)
    {
        if(Sheets.Item("附表3").Range("I"+i).Value2!=sl)
            Sheets.Item("附表3").Range("I"+i).EntireRow.Delete(xlShiftUp);
    }
    ActiveWorkbook.SaveAs("/data/" + sl + ".xlsx", undefined, undefined, undefined, undefined, undefined, xlNoChange, 1, -1, undefined, undefined);
    MsgBox("保存成功");
}

BeautifulSoup修改text值

注意:target.text能获取text的值,但是无法修改text值,要用target.string修改

from bs4 import BeautifulSoup
import os

with open("index.html","r",encoding="utf-8") as htmlfile:
    html=htmlfile.read()
    soup = BeautifulSoup(html, 'lxml')  #生成BeautifulSoup对象
    targets = soup.find_all('a') #所有名称为a的节点
    for target in targets:
        #此地不能用target.text
        target.string="中卫日报("+target["href"][27:37]+")"
        htfile=os.path.join(os.getcwd(),target["href"])
        print(htfile)
        #if os.path.exists(htfile):
        #    target["style"]="color:red;"
        #else:
        #    target["style"]="color:green;"

with open("index.html","w") as fp:
    fp.write(soup.prettify())

银河麒麟v10安装python3.10

经测试网上教程可用,参考地址:
https://www.yilvhun.com/1038.html
因自己下载的是3.10.4,做链接的时候就统一用的310.

安装后效果:

存在问题:按照该方法安装后缺少ssl导致pip无法使用。

经网上查找到的解决方法:
1.编译安装openssl。系统自带的版本太低用不了,编译安装python已经吐了,这个再编译安装已经吐了,不再测试。
2.临时解决方案:
pip310 install --trusted-host mirrors.aliyun.com pytest -i http://mirrors.aliyun.com/pypi/simple/

https加载http资源This request has been blocked

Mixed Content: The page at 'https://' was loaded over HTTPS, but requested an insecure form action 'http://*'. This request has been blocked; the content must be served over HTTPS.
网上给的的解决方案:

一、改代码

在head标签中添加代码

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

要个有权力改代码并且http资源http是能访问这种方式最好

二、参考网上修改

https://www.freesion.com/article/98191289626/
这种方式不用改代码,改浏览器设置即可。

三、改浏览器设置,同上

区别在于我用的360浏览器没弹出上面方式的提示。

点击“加载不安全的脚本”后页面会自动刷新,然后就能正常使用了