我有一个大文件,每行有4个数字。现在我想要在每个数字之前添加8个零。我怎么能用Bash或Python做到这一点?
答案 0 :(得分:0)
这应该有效:
myfile = open("filename.txt")
items = myfile.read().split("\n")
mystr = ""
for x in range(0, len(items)):
mystr += "00000000" + items[x] + "\n"
myfile = open("filename.txt", 'w')
myfile.write(mystr)
myfile.close()