python - #python 2.7 如何运行长度解码(RLE 到字符串)
问题描述
我希望将 RLE 的一部分解码为非编码输出,例如:
01,01a01d57801d01a01,
进入
,ad888888888888888888888888888888888888888888888888888888888da,
我曾尝试使用此模块:
def decode(lst):
return ''.join(c * n for n,c in lst)
但这给了我一个“太多的价值来解包”任何帮助将不胜感激。我不知道如何解决这个问题,即使不修复我的模块也可以,请任何帮助都是好的。
解决方案
哇
import re
def decode(lst):
return ''.join(c * int(n) for n,c in lst)
def openingthefile():
x=1
myfile=open('LogoRLE.txt','r')
details =myfile.readline()
while details is not "":
mylist=re.findall(r'(\d\d)?(.)', details)
print decode(mylist)
details=myfile.readline()
myfile.close()
return details
contents=openingthefile()
mylist=re.findall(r'(\d\d)?(.)', contents)
推荐阅读
- javascript - 如何将单个对象内的两个数组合并为属性
- c - 为什么我的附加功能没有显示输出?
- flutter - StreamProvider 不更新列表(Firestore)
- javascript - 隐藏和显示功能在 jquery 中不起作用
- c++ - 最大矩阵成本路径,
- apache-kafka - Producer的本地缓存中如何存储schema(已在Schema Registry中注册)
- ios - fastlane 错误无法打开与 olympus.itunes.apple.com:443 的 TCP 连接(getaddrinfo:提供节点名或服务名,或未知)
- javascript - JavaScript 将视频帧绘制到画布上
- vb.net - 附加信息:无法对 System.String 和 System.Int32 执行“>”操作
- python - 从模块导入类时出错