剪切板a_bcd -> ABcd

还在一个一个把下划线后小写字母改成大写吗?

快来试试这个小工具吧。

按一下快捷键就可以自动把 a_a -> AA         a_bcd -> ABcd

github:GitHub - huangwenzi/clip_board_to_val_name: clip_board to val name 剪切板内容替换成变量名

github内有exe可直接使用

代码

import win32clipboard as w
import win32con
from pynput import keyboard
import json


# 获取剪切板
def get_text():
    w.OpenClipboard()
    d = w.GetClipboardData(win32con.CF_TEXT)
    w.CloseClipboard()
    return d.decode('GBK')

# 设置剪切板
def set_text(aString):
    w.OpenClipboard()
    w.EmptyClipboard()
    w.SetClipboardData(win32con.CF_UNICODETEXT, aString)
    w.CloseClipboard()

# 键盘事件
def on_press(key):
    if print_key:
        print(key)
        
    # 是否是快捷键
    if key != keyboard.Key[replace_key]:
        return
    
    # 检查长度
    text:str = get_text()
    if len(text) > replace_len:
        return
    
    # 检查类型
    status = False
    new_text = ""
    if replace_type == 1:
        text_list:list = text.split("_")
        if len(text_list) > 0:
            for item in text_list:
                new_text += (item[0].upper() + item[1:])
            status = True
    else:
        return

    if status:
        print(new_text)
        set_text(new_text)
    

# 加载配置
cfg = {}
with open("./cfg.json", encoding="utf8") as f:
    cfg = json.load(f)
replace_key = cfg["replace_key"]
replace_type = cfg["replace_type"]
replace_len = cfg["replace_len"]
print_key = cfg["print_key"]

# 开始监听
print("begin")
with keyboard.Listener(on_press=on_press) as lsn:
    lsn.join()

配置

cfg.json

{
    "replace_key" : "alt_gr"
    , "replace_type" : 1
    , "replace_len" : 30
    , "print_key" : false
    , "notes" : "replace_key: 替换的快捷键 推荐alt_gr 右侧ctrl  replace_type: 替换类型 1、aa_bb => AaBb  replace_len: 替换的字符串长度上限  print_key: 是否打印按下的键"
}

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行

csdn文章推荐受影响解决办法10个字10行
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码什么意思 include 'vaba_param.inc' c c 3D Orthotropic Elasticity with Hashin 3d Failure criterion c c The state variables are stored as: c state(*,1) = material point status c state(*,2:7) = damping stresses c c User defined material properties are stored as c * First line: c props(1) --> Young's modulus in 1-direction, E1 c props(2) --> Young's modulus in 2-direction, E2 c props(3) --> Young's modulus in 3-direction, E3 c props(4) --> Poisson's ratio, nu12 c props(5) --> Poisson's ratio, nu13 c props(6) --> Poisson's ratio, nu23 c props(7) --> Shear modulus, G12 c props(8) --> Shear modulus, G13 c c * Second line: c props(9) --> Shear modulus, G23 c props(10) --> beta damping parameter c props(11) --> "not used" c props(12) --> "not used" c props(13) --> "not used" c props(14) --> "not used" c props(15) --> "not used" c props(16) --> "not used" c c * Third line: c props(17) --> Ultimate tens stress in 1-direction, sigu1t c props(18) --> Ultimate comp stress in 1-direction, sigu1c c props(19) --> Ultimate tens stress in 2-direction, sigu2t c props(20) --> Ultimate comp stress in 2-direction, sigu2c c props(21) --> Ultimate tens stress in 2-direction, sigu3t c props(22) --> Ultimate comp stress in 2-direction, sigu3c c props(23) --> "not used" c props(24) --> "not used" c c * Fourth line: c props(25) --> Ultimate shear stress, sigu12 c props(26) --> Ultimate shear stress, sigu13 c props(27) --> Ultimate shear stress, sigu23 c props(28) --> "not used" c props(29) --> "not used" c props(30) --> "not used" c props(31) --> "not used" c props(32) --> "not used"
06-07

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值