python小程序——txt文件内容改写
# This is a sample Python script. import sys import re import os def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. import sys def lm_replace(file, fileName): f = open(file,"r+") content_before = f.read() #print(content_before) # 将blendNormal 替换为 blendScreen content_after = content_before.replace("ADAMS SIM TIME = 1.0100e+02", fileName) #print(content_after) f.seek(0,0) f.truncate() #清空文件,配合seek使用,否则清空的位置不对 f.write(content_after) f.close() if __name__ == '__main__': print("数据文件夹:") rawDir = input() fileList = os.listdir(rawDir) rawDir = rawDir + "\\" # write data for temFile in fileList: file = rawDir + temFile lm_replace(file, temFile) print_hi('done')
pyinstaller -F ***.py
一、安装 pyinstaller
pip install pyinstaller
二、使用 pyinstaller 命令
pyinstaller -F --icon=my.ico test.py #打包成exe,并设置图标
pyinstaller -F -w yourfilename.py #打包成exe,且不包含控制台
其他参数:

一般 python GUI编程才用到 打包成exe,讲道理不如.net 的winform好使
记录每天生活的点点滴滴,呵呵呵呵呵呵

浙公网安备 33010602011771号