如果要insert一堆字段
number, status, user_id, address_book_id, order_time, checkout_time, pay_method, pay_status,
amount, remark, phone, address, user_name, consignee, cancel_reason, rejection_reason,
cancel_time, estimated_delivery_time, delivery_status, delivery_time, pack_amount,
tableware_number, tableware_status
要一个个的#{nuber}十分繁琐
所以借此写一个python的脚本处理字符串
import pyperclip as pc
input_text = ''
while True:
line = input()
if not line:
break # 当输入为空行时结束输入
input_text += line + '\n'
a = input_text.replace("\n", "").replace(" ", "").split(",")
print(a)
b = ""
for i, j in enumerate(a):
if j.strip(): # 检查字段名称是否非空
while True:
try:
idx = j.index("_")
j = j.replace(j[idx] + j[idx + 1], j[idx + 1].upper())
except ValueError:
break
b += "#{" + j + "}"
if i != len(a) - 1: # 避免在最后一个字段后添加逗号
b += ","
print(b)
pc.copy(b)