<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      自己封裝的 Python 常用工具庫(kù)(prestool)

      一、安裝

      需Python 版本建議 3.7 以上

      pip install --upgrade  prestool
      

      二、常用工具

      from prestool.Tool import Tool
      tool = Tool()
      

      1、隨機(jī)數(shù)據(jù)

      tool.random_name()  # 隨機(jī)姓名
      tool.random_phone()  # 隨機(jī)手機(jī)號(hào)
      tool.random_ssn()  # 隨機(jī)身份證
      
      tool.random_string(16)  # 隨機(jī)位數(shù)的字符串
      tool.random_number(8)  # 隨機(jī)位數(shù)的數(shù)字
      
      tool.random_ua()  # 隨機(jī)UA
      tool.random_ua('chrome')  # 隨機(jī)UA-Chrome
      tool.random_ua('firefox')  # 隨機(jī)UA-Firefox
      tool.random_ua('ie')  # 隨機(jī)UA-IE
      tool.random_ua('opera')  # 隨機(jī)UA-opera
      tool.random_ua('safari')  # 隨機(jī)UA-safari
      

      2、編碼解碼

      tool.url_encode('編碼前的url地址')  # 編碼
      tool.url_decode('解碼前的url地址')  # 解碼
      
      tool.base_64_encode('編碼前的字符串')  # base64編碼
      

      3、加密相關(guān)

      tool.to_md5('原始字符串')
      tool.to_hmac_256('原始字符串', '加密key')
      tool.to_sha_256('原始字符串')
      

      4、發(fā)送消息

      # 釘釘
      tool.ding_talk_token = '釘釘機(jī)器人token'
      tool.ding_talk_sign_key = '釘釘機(jī)器人簽名key'
      tool.send_ding_talk_msg('消息內(nèi)容')
      
      # 企業(yè)微信
      tool.qy_wechat_token = '企業(yè)微信機(jī)器人token'
      tool.send_qy_wechat_msg('消息內(nèi)容')
      
      # 郵件
      tool.mail_from_user_host = '發(fā)件地址host'
      tool.mail_from_user = '發(fā)件人郵箱號(hào)'
      tool.mail_from_user_pwd = '發(fā)件人pwd'
      tool.send_mail_msg(to_user='收件人郵箱地址(列表)', title='郵件標(biāo)題', content='郵件內(nèi)容')
      

      5、時(shí)間相關(guān)

      tool.time_stamp()  # 秒級(jí)時(shí)間戳10位
      tool.time_stamp('ms')  # 毫秒級(jí)時(shí)間戳13位
      
      tool.get_now_time()  # 獲取當(dāng)前時(shí)間 20201206000000
      tool.get_now_time('-')  # 獲取當(dāng)前時(shí)間 2020-12-06 00:00:00
      
      tool.date_to_time_stamp('2012-01-01 00:00:00')  # 時(shí)間字符串轉(zhuǎn)為時(shí)間戳
      tool.time_stamp_to_date(1732312234)  # 時(shí)間戳轉(zhuǎn)為時(shí)間字符串
      

      6、格式轉(zhuǎn)換

      tool.json_dumps({"test": "python字典"})  # 字典轉(zhuǎn)json
      tool.json_loads('{"test": "python字典"}')  # json轉(zhuǎn)字典
      tool.xml_to_dict('<xml><data>字符串</data></xml>')  # xml轉(zhuǎn)成python字典
      tool.dict_to_xml({"test": "python字典"})  # python字典 轉(zhuǎn)成xml
      

      7、http 請(qǐng)求

      tool.http_client(url='', data={}, method='GET')  # get請(qǐng)求
      tool.http_client(url='', data={}, method='POST')  # post請(qǐng)求
      
      tool.get_cookies(url='接口地址', data={}, method='GET')
      tool.get_cookies(url='接口地址', data={}, method='POST')
      
      tool.trans_data_to_url(url='接口地址', data={})  # 把參數(shù)拼接到url上
      

      8、dubbo 接口

      tool.dubbo_args('參數(shù)1', '參數(shù)2', '參數(shù)3')  # dubbo接口參數(shù)
      tool.invoke_dubbo('地址', '端口', '服務(wù)API名', '接口方法名', 'dubbo接口參數(shù)')  # 請(qǐng)求dubbo接口
      

      9、其他

      tool.logger('日志信息')
      tool.get_ip_by_url('url地址')  # 獲取ip
      

      三、數(shù)據(jù)庫(kù)語(yǔ)句(MySQL)

      1、生成數(shù)據(jù)庫(kù) sql 語(yǔ)句

      from prestool.PresMySql import SqlStr
      sql = SqlStr()
      

      2、查詢語(yǔ)句

      # target 不傳時(shí),為全部字段,即 *,where={'key':'value'}
      sql.select_sql_str(table='table1', where={'id': 1, 'name': '張三'})
      select * from table1 where id = 1 and name = '張三';
      
      # target=[i1,i2,i3] 時(shí),為相應(yīng)字段
      sql.select_sql_str(table='table1', target=['a', 'b', 'c'], where={'id': 1, 'name': '張三'})
      select a, b, c from table1 where 1=1 and id=1 and name='張三';
      
      # limit=10 limit='10,1000' 為篩選限制字段
      sql.select_sql_str(table='table1', target=['a', 'b', 'c'], order={'age': 'desc', 'score': 'desc'}, limit=20)
      select a, b, c from table1 where 1=1 order by age desc, score desc limit 20;
      
      # where 條件中有的字段為 null 或者 not null 時(shí)
      sql.select_sql_str(table='table1', target=['a', 'b', 'c'], where={'id': 1, 'name': 'null', 'age': not None})
      select a, b, c from table1 where 1=1 and id=1 and name is null and age is not null;
      
      
      # 支持排序語(yǔ)句
      sql.select_sql_str(table='table1', target=['a', 'b', 'c'], order={'age': 'desc', 'score': 'desc'})
      select a, b, c from table1 order by age desc, score desc;
      
      # 支持查詢 in 語(yǔ)句
      sql.select_sql_str(table='table1', target=['a', 'b', 'c'], select_in={'orders': [123121312, 123123445, 213123]})
      select a, b, c from table1 where 1=1 and orders in (123121312, 123123445, 213123);
      
      # 支持 like 語(yǔ)句
      sql.select_sql_str(table='table1', target=['a', 'b', 'c'], like={'name': '%光', 'address': "中國(guó)%"})
      select a, b, c from table1 where 1=1 and name like '%光' and address like '中國(guó)%';
      
      # 支持 between 語(yǔ)句
      sql.select_sql_str(table='table1', target=['a', 'b', 'c'], between={'age': (10, 20), 'year': (2021, 2022)})
      select a, b, c from table1 where 1=1 and age between 10 and 20 and year between 2021 and 2022;
      
      # 支持大于、小于語(yǔ)句
      sql.select_sql_str(table='table1', target=['a', 'b', 'c'],
                             compare={'age': {'>': 10, '<': 20}, 'year': {'>=': '2021'}})
      
      select a, b, c from table1 where 1=1 and age > 10 and age < 20 and year >= 2021;
      
      # 更新語(yǔ)句
      target 為要更新的數(shù)據(jù),為字典結(jié)構(gòu) (支持大于、小于語(yǔ)句、between 語(yǔ)句、like 語(yǔ)句、in 語(yǔ)句)
      sql.update_sql_str(table='table1', target={'name': '李四', 'age': 15}, where={'id': 1, 'name': '張三'})
      update table1
      set name='李四',
          age=15
      where id = 1
        and name = '張三';
      
      # 刪除數(shù)據(jù)
      支持大于、小于語(yǔ)句、between 語(yǔ)句、like 語(yǔ)句、in 語(yǔ)句
      sql.delete_sql_str(table='table1', where={'id': 1, 'name': '張三'})
      delete
      from table1
      where id = 1
        and name = '張三';
        
      # 插入數(shù)據(jù)
      sql.insert_sql_str(table='table1', target={'id': 1, 'name': '張三'})
      insert into table1 (id, name)
      values (1, '張三');
      

      2、執(zhí)行數(shù)據(jù)庫(kù)語(yǔ)句

      from prestool.PresMySql import PresMySql
      
      pres = PresMySql()
      # 初始化數(shù)據(jù)庫(kù)信息
      pres.mysql_host = ''
      pres.mysql_port = 3306
      pres.mysql_user = ''
      pres.mysql_pwd = ''
      pres.mysql_db_name = ''
      pres.mysql_charset = 'utf8mb4'
      

      執(zhí)行相應(yīng)語(yǔ)句即可,執(zhí)行的方法參數(shù)等同于第三節(jié)所述的 sql 語(yǔ)句,如

      pres.to_query(table='table1', target=['a', 'b', 'c'], between={'age': (10, 20), 'year': (2021, 2022)})
      pres.to_insert(table='table1', target={'id': 1, 'name': '張三'})
      pres.to_delete(table='table1', where={'id': 1, 'name': '張三'})
      pres.to_update(table='table1', target={'name': '李四', 'age': 15}, where={'id': 1, 'name': '張三'})
      
      posted @ 2022-03-15 09:47  狂師  閱讀(268)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 久久久久人妻一区二区三区| 亚洲岛国成人免费av| 大又大又粗又硬又爽少妇毛片| 亚洲色欲或者高潮影院| 国产99视频精品免费视频36| 日韩有码中文字幕第一页| 国产成人小视频| 亚洲精品国产无套在线观| 澳门永久av免费网站| 珠海市| 狠狠v日韩v欧美v| 亚洲中文字幕无码av永久| 7878成人国产在线观看| 国产激情第一区二区三区| 精品国产亚洲一区二区三区| 亚洲成av人片天堂网无码| 国产99视频精品免费观看9| 国产精品高清视亚洲乱码| 亚洲色拍拍噜噜噜最新网站| 东平县| 亚洲乱熟女一区二区三区| 亚洲欧美综合精品二区| 巨胸爆乳美女露双奶头挤奶| 污网站在线观看视频| 中文无码人妻有码人妻中文字幕| 人人澡超碰碰97碰碰碰| 深田えいみ禁欲后被隔壁人妻| 国产精品久久久久久福利| 国产美女裸身网站免费观看视频 | 精品国产AV最大网站| 最新国产AV最新国产在钱| 亚洲精品国产美女久久久| 精品国产一区二区三区大| 综合激情网一区二区三区| 在线播放免费人成毛片| 毛片内射久久久一区| 18禁在线一区二区三区| 国产成人欧美综合在线影院| 亚洲一区二区av偷偷| 成人网站免费观看永久视频下载| 久爱www人成免费网站|