JS 字符串数组的连接 array.join

使用 Array.prototype.join() 以下内容参考 MDN web docs join() 方法将数组中所有元素成一个新的字符串并返回。默认使用逗号作为分隔符或使用指定的分隔字符。 语法: Array.join( ) Array.join(separator) 举例: // Code copied from

cURL post JSON 数据

使用 curl 通过 post 方法提交 json 格式的数据: curl --request POST \ --header "Content-Type: application/json" \ --data '{"foo":"bar","num":1}' \ http://localhost:3000/path/ 参数说明: --request POST, 可选。当使用 --data 选项时,默认就是 post 方法

Python 执行命令行程序并返回结果

使用 pexpect 库比较省心,使用方便。也不像使用 subprocess 会出现很多问题。 代码: import pexpect def execute_cli_command(cmd: str) -> str: """return stdout:str""" (command_output, exitstatus) = pexpect.run(cmd, withexitstatus=1) command_output = command_output.decode("utf-8") if exitstatus != 0: raise Exception(exitstatus, command_output) return command_output

Git 替换分支(覆盖分支)

假设要将 main 分支完全替换成 dev 分支的内容(即用 dev 分支内容覆盖 main 分支内容): git checkout dev git merge -s ours main git checkout main git merge dev 命令说明: git checkout dev:将当前工作目录切换到

macOS 如何关闭自启动的后台服务进程

删除如下三个目录中的 .plist 文件,或转移到一个备份文件夹里。 ~/Library/LaunchAgents/ ~/Library/LaunchAgents/ ~/Library/LaunchDaemons/ Quote from ravbug.com: OS to automatically run and re-launch headless background processes. There are at minimum three such folders on macOS. They are: /Library/LaunchAgents, ~/Library/LaunchAgents/, and /Library/LaunchDaemons

Python 删除文件夹

pathlib.Path.unlink() removes a file or symbolic link. 删除单个文件或文件符号链接 os.rmdir() 或 pathlib.Path.rmdir() removes an empty directory. 删除一个空文件夹 os.removedirs() remove recursive empty directories 删除多层的空文件夹 shutil.rmtree() deletes a directory and all its contents. 删除文件夹,包括其中所有子