有些公司因为历史原因
在Build react,vue,npm等相关专案
需经过 前置的处理作业
这里汇整相关指令 做为纪录参考
1.读取外部设定档
import configparser
cf = configparser.ConfigParser()
filename = "config.ini"
cf.read(filename)
读取到後还需要 set指定类别 参数 ,替换的内容
cf.set("category", "build_path" , pc_build_path_ )
2.替换档案里的文字
def alter(file,old_str,new_str):
file_data = ""
with open(file, "r", encoding="utf-8") as f:
for line in f:
if old_str in line:
line = line.replace(old_str,new_str)
file_data += line
with open(file,"w",encoding="utf-8") as f:
f.write(file_data)
3.对目录拷贝与删除
import shutil
shutil.rmtree('delete path')
shutil.copytree('ori path','target path')
4.对档案操作 目录切换
import os
os.chdir(_path_+"/");
f = open('src/Config.js',"r",encoding="utf-8")
text = f.read()
os.system("yarn build")
6.可能还需要简单介面做视觉化处理
import tkinter as tk
from tkinter import *
from tkinter.filedialog import askdirectory
7.如果一次处理多个任务
或是视觉介面触发时,另外提供一个执行绪来做处理
( 不做处理,很有可能会看到你的介面卡住)
import threading
t = threading.Thread(target = target_function )
8.打包exe
pip install pyinstaller
pyinstaller.exe --onefile --icon=desktop.ico -w pc.py
打包遇到指令无法辨识
请参考
[Python 生成 Windows 执行档教学](https://ithelp.ithome.com.tw/articles/10231524)
常用参数介绍
pyinstaller -h 来查看参数
-F 打包成一个exe文件
–icon=图标路径
-w 使用视窗,无控制台
-c 使用控制台,无视窗
-D 创建一个目录,包含exe以及其他一些依赖性文件
如果单纯从学习Ruby再学习运用Rails开发网页专案,那可能还要再认识一些技能,对开发上能更有帮助...
『电脑科学由於硬体的限制,存在计算的误差。从同一道数学问题,透过 程序解与手动解析解来观察此一现象最...
哈罗大家好!我是阿关 是说第一次参加铁人赛就想要挑战一个自己完全不熟悉的题目 我也是觉得自己蛮有勇...
欸!?这个不是在 hello world 的时候讲过了ㄇ?! 对。 其实函式还是有其他东西可以讲解的...
优缺点 优点 Block storage最大的优点就是他使得计算与储存分离,我们能轻易地透过LUN ...