trigger: 在服务器上跑代码,本地更改,安利gtk代码同步工具,但在服务器上对代码库进行 commit 或者diff,project大,寻找路径,索引繁琐,遂做个路径转换的小脚本
consider到有转义字符的转换问题
tool:剪切板访问工具 —-pyperclip,
常用函数
recommend:
pyperclip.copy()
pyperclip.paste()
源代码
#author:richard.shao
import pyperclip
inPath = pyperclip.paste()
print inPath
outPath = inPath.replace('\\','/')
outPath = outPath.strip(':')
print type(outPath)
pyperclip.copy(outPath)
bug_fix:replace 返回替换的字符串而不是修改原字符串
outPath = outPath.replace(“:\”,’/’)思路不对,逻辑问题,:后的反斜杠已经删除,遂,用stript
advance: make variable meaningful