测试
a=("ab/cd/ef", "ab/cd/ef/g", "ab/cd/")
输出
{'ab/cd/': 1}
[code]
#in_set 应是一个有序的字符串集合
def remove_duplicate_string(in_set):
if len(in_set) < 2:
return in_set
duplicate_str_dict = {}
same_str_dict = {}
old_str = ""
same_str = ""
for str in in_set:
if len(same_str) > 1:
if str.find(same_str) >= 0: # same_str 应该是两个字符串的交集,如果能跟same_str匹配,则直接pass
continue
if len(old_str) > 0:
same_str = get_same_string(old_str, str)
print(f"{same_str} vs {old_str} vs {str}")
if len(same_str) > 1:
same_str_dict[same_str] = 1
old_str = str
if len(same_str_dict) < 1 or len(same_str_dict) == len(in_set):
return in_set
if len(same_str_dict) < len(in_set):
return remove_duplicate_string(same_str_dict)
return same_str_dict
[/code]
2021-10-07
python批量提取一个set中,最小相同路径
2021-09-17
python分析java class字节码工具 javatools demo
在windows下安装python-javatools包
参考:https://stackoverflow.com/questions/30344200/m2crypto-installation
https://community.anaplan.com/t5/Anaplan-Platform/Installing-M2Crypto-Python-Library-on-Windows-Machine-for/m-p/79950#M17164
环境:
Python3.8
Windows10
主要问题卡在依赖的 M2Crypto 上,要安装这个python package,需要安装openssl + swig ,然后用swig根据openssl 的头文件结合 M2Crypto的源文件,生成 中间代码,再用编译器编译
根据 M2Crypto介绍说可以支持mingw(https://gitlab.com/m2crypto/m2crypto/-/blob/master/INSTALL.rst#differences-when-installing-on-windows),开始就想用Cygwin或mingw的gcc来试一试,这两个环境比较干净,可以不用安装太多windows程序,只是最新的cygwin/mingw都用gcc 11了,也不知道是gcc11版本做了什么改动,链接时总是提示无法找到 fdopen等函数
最后还是屈服在MS淫威之下,一次安装通过。。。
2021-09-16
通过setup.py 传递编译参数给 gcc
参考:https://docs.python.org/zh-cn/3.10/distutils/configfile.html
https://www.pythonf.cn/read/168890
编译 M2Crypto时遇到 openssl 头文件找不到,可以用setup.py 的build_ext模式,将额外参数传递给swig(或gcc)
python setup.py build_ext -I/d/soft/msys64/mingw64/include –openssl /d/openssl -cmingw32
xargs 与 cp 连用
find《from dir》 -type f -name ‘*.jar’|grep -v ‘/lib/’|grep -v sources|xargs -i cp {} <to dir>