软件介绍
这次Go破解分享两款 文档段落排版 的软件,相信大家也有遇到过这种问题。在网上下载的 TXT小说 或是 Word文档 以及 PDF文件 有许多都没有进行排版或是排版不到位,还有就是复制问题 反正看着不舒服。当然还有就是专门写文档的,有些地方忘记段落或是写东西没有排版的习惯。需要的赶紧下载相当好用。
第一款 天若段落排版
第二款 没有名字 文件段落整理
这款文件段落整理是开源的源码会附下方,喜欢研究编程的小伙伴可以研究研究,两款软件下载都在最下方。
#-*-coding:GBK -*-
#print(" ")
print(" _____ _____ _____ _____ ____ ")
print(" ___|\ \ |\ \ / /||\ \ _____ | |")
print("| |\ \ | \ \ / / || | | / /| | |")
print("| | | || \____\/ / /\/ / | || | |")
print("| | /_ _ / \ | / / / / /_ \ \/ ____ | |")
print("| |\ \ \|___/ / / | // \ \ \ | | | |")
print("| | | | / / / | |/ \ | || | | |")
print("|____|/____/| /____/ / |\ ___/\ \| /||\____\|____|")
print("| / || |` | / | | | \______/ || | | |")
print("|____|_____|/ |_____|/ \|___|/\ | | | \|____|____|")
print(" \( )/ )/ \( \|____|/ \( )/ ")
print(" ' ' ' ' )/ ' ' ")
print(" ' ")
""""""
import tkinter as tk
from tkinter import filedialog, dialog,messagebox
import oswindow = tk.Tk()
window.title('文件段落整理') # 标题
window.geometry('600x380+600+200') # 窗口尺寸
window.resizable(width=False, height=False) #限制改变尺寸
#A9E024
file_path = ''file_text = ''
dirname=''
#FFFFFF
text1 = tk.Text(window, width=50, height=10, bg='#A9E024', font=('Arial', 12))
text1.place(x=10,y=10,width=580,height=320)def open_file():
'''
打开文件
:return:
'''
global file_path
global file_text
global dirnamecontents = text1.get(0.0,tk.END).strip()
if contents !="":
text1.delete('1.0', tk.END)
if dirname=="":
dirname=os.getcwd()
file_path = filedialog.askopenfilename(title=u'打开文件',
filetypes=[('TXT', '*.TXT'), ('All Files', '*')],
initialdir=dirname)
print('打开文件:', file_path)
if file_path is not None:
with open(file=file_path, mode='r+', encoding='UTF-8') as file:
file_text = file.read()
text1.insert('insert', file_text)def save_file():
global file_path
global file_text
global filename1
global dirname
contents = text1.get(0.0,tk.END).strip()
#print (len(contents))
if contents=="":
tk.messagebox.showinfo('文件不存在','请打开文件操作!')
open_file()
deal_file()
filename2=os.path.basename(filename1)
file_path1 = filedialog.asksaveasfilename(title=u'保存文件',
initialfile=filename2,
filetypes=[('TXT', '*.TXT'), ('All Files', '*')],
initialdir=dirname)
print('保存文件:', file_path1)
file_text = text1.get('1.0', tk.END)
if file_path1 is not None:
with open(file=file_path1, mode='a+', encoding='UTF-8') as file:
file.write(file_text)
text1.delete('1.0', tk.END)
tk.messagebox.showinfo('文件存储完毕',file_path1+'保存完成')
print('保存完成')def deal_file():
global file_path
global file_text
global dirname
global filename1
if file_path=="":
open_file()
dirname,filename=os.path.split(file_path)
print ('处理文件名',filename)
line1=" "
with open(file_path,'r',encoding='UTF-8') as file_object:
lines = file_object.readlines()
for line in lines: #lines[0:10]:
line=line.strip()
#print(line.strip())
if len(line)==0:
pass
else:
if line[-1:]=="。" or line[-1:]=="”" :
line=line+"\n "
#print (line[-4:-1],"***",line[-4:-1],"***")
if line[0]=="”":
if line1[-4:-1]==" "[-4:-1]:
line1=line1[:-5]+"”\n "else:
line1=line1+"”"
line=line[1:]
line1=line1+line
#print(line1)
text1.delete('1.0', tk.END)
text1.insert('insert', line1)filename1,filesuffix = os.path.splitext(filename)
filename1=os.path.join(dirname,filename1+"1"+filesuffix)
print (filename1)
with open(filename1,'w',encoding='UTF-8') as file_object:
file_object.write(line1)bt1 = tk.Button(window, text='打开文件', width=15, height=2,command=open_file)
bt1.place(x=80,y=340,width=70,height=30)
bt3 = tk.Button(window, text='整理文件', width=15, height=2, command=deal_file)
bt3.place(x=265,y=340,width=70,height=30)
#bt3.grid(row=0,column=1)
#bt3.pack()
bt2 = tk.Button(window, text='保存文件', width=15, height=2, command=save_file)
bt2.place(x=450,y=340,width=70,height=30)
#bt3.grid(row=0,column=2)
#bt2.pack()window.mainloop() # 显示
自动每个段落前面空格?如果文章很长的话那挺方便的,短文章没必要