Skip to main content

prestool

Project description

一、安装(python版本 python3.6+)

pip install --upgrade  prestool

二、使用

from prestool.Tool import Tool
tool = Tool()

随机数据

tool.random_name()  # 随机姓名
tool.random_phone()  # 随机手机号
tool.random_ssn()  # 随机身份证

tool.random_string(16)  # 随机位数的字符串
tool.random_number(8)  # 随机位数的数字

tool.random_ua()  # 随机UA
tool.random_ua('chrome')  # 随机UA-Chrome
tool.random_ua('firefox')  # 随机UA-Firefox
tool.random_ua('ie')  # 随机UA-IE
tool.random_ua('opera')  # 随机UA-opera
tool.random_ua('safari')  # 随机UA-safari

记录日志

tool.logger('日志信息')

加密相关

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

发送钉钉webhook消息

tool.ding_talk_token = '钉钉机器人token'
tool.ding_talk_sign_key = '钉钉机器人签名key'

tool.send_ding_talk_msg('消息内容')

发送企业微信webhook消息

tool.qy_wechat_token = '企业微信机器人token'

tool.send_qy_wechat_msg('消息内容')

发送邮件消息

tool.mail_from_user_host = '发件地址host'
tool.mail_from_user = '发件人邮箱号'
tool.mail_from_user_pwd = '发件人密码'

tool.send_mail_msg(to_user='收件人邮箱地址(列表)', title='邮件标题', content='邮件内容')

时间相关

tool.time_stamp()  # 秒级时间戳10位
tool.time_stamp('ms')  # 毫秒级时间戳13位

tool.get_now_time()  # 获取当前时间 20201206000000
tool.get_now_time('-')  # 获取当前时间 2020-12-06 00:00:00

格式转换

tool.json_dumps({"test": "python字典"})  # 字典转json
tool.json_loads('{"test": "python字典"}')  # json转字典

tool.xml_to_dict('xml字符串')

http请求

tool.http_client(url='', data={}, method='GET')
tool.http_client(url='', data={}, method='POST')

tool.get_cookies(url='接口地址', data={}, method='GET')
tool.get_cookies(url='接口地址', data={}, method='POST')

tool.trans_data_to_url(url='接口地址', data={})  # 把参数拼接到url上

编码解码

tool.url_encode('编码前的url地址')  # 编码
tool.url_decode('解码前的url地址')  # 解码

tool.base_64_encode('编码前的字符串')  # base64编码

dubbo接口

tool.dubbo_args('参数1', '参数2', '参数3')  # dubbo接口参数
tool.invoke_dubbo('地址', '端口', '服务API名', '接口方法名', 'dubbo接口参数')  # 请求dubbo接口

其他

tool.get_ip_by_url('url地址')  # 获取ip
# 上传到pypi相关
python setup.py bdist_wheel --universal
twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prestool-0.0.19-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file prestool-0.0.19-py2.py3-none-any.whl.

File metadata

  • Download URL: prestool-0.0.19-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.3

File hashes

Hashes for prestool-0.0.19-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 34a358784196e78fe9ee9d40828458bcd6444bfea4794fbe5ec15c4b5aaf7fa0
MD5 6945d49a0c00d6bb895e4cde644b4d8a
BLAKE2b-256 90bd857c12b3590c3e9d36699ca5066b3fdb497504c5459a58a012acb8008f41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page