tmtool
Project description
tm-pip-tools
工具集合
上传pypi
python setup.py bdist_wheel
twine upload dist/*
安装(Python 版本>=3.8.0)
pip install --upgrade tmtoolP
使用
发送邮件
from tmtool.tools import Tool
tool = Tool()
tool.mail_from_user_host = '发件地址host'
tool.mail_from_user = '发件人邮箱号'
tool.mail_from_user_pwd = '发件人密码'
tool.send_mail_msg(to_user='收件人邮箱地址(这里是列表,可填写多个)', title='邮件标题', content='邮件内容')
格式转换
tool.json_dumps({"test": "python字典"}) # 字典转字符串
tool.json_loads('{"test": "python字典"}') # 字符串转字典
tool.xml_to_dict('<xml><data>字符串</data></xml>') # xml转字典
tool.dict_to_xml({"test": "python字典"}) # 字典转xml
企业微信机器人
from tmtool.tools import Tool
tool = Tool()
tool.qy_wechat_token = '7fdda192-cfcb-4eb5-87a5-b341574562d5'
# @ 所有人
tool.send_qy_wechat_msg("自测内容,忽略!", at_all=['@all'])
# @ 指定人
tool.send_qy_wechat_msg("自测内容,忽略!", at_all=['18600967174'])
# @ 指定多人
tool.send_qy_wechat_msg("自测内容,忽略!", at_all=['18600967174', '15210205078'])
时间转换
tool.time_stamp() # 10位秒级时间戳
tool.time_stamp('ms') # 13位毫秒时间戳
tool.get_now_time() # 获取当前时间
tool.date_to_time_stamp('2022-03-25 00:00:00') # 时间字符串转为时间戳
tool.time_stamp_to_date(1732312234) # 时间戳转为时间字符串
随机数据
tool.random_phone() # 随机手机号
tool.random_name() # 随机姓名
tool.random_ssn() # 随机身份证
tool.random_string(16) # 随机位数的字符串
tool.random_number(8) # 随机位数的数字
http请求
tool.http_client(url='', data={}, method='GET') # get请求
tool.http_client(url='', data={}, method='POST') # post请求 -(暂无header #TODO)
tool.trans_data_to_url(url='接口地址', data={}) # 把参数拼接到url上
MySQL数据库相关
# 生成sql语句
from tmtool.TmMySQL import SqlStr
tmsql = SqlStr()
# 查询语句 -> target不传时,为全部字段,即*,where={'key':'value'}
tmsql.select_sql_str(table='user', where={'id': 1, 'nick_name': '测试用户'})
# 查询语句 -> target=[i1,i2,i3]时,为相应表字段
tmsql.select_sql_str(table='user', target=['username', 'password'], where={'id': 1, 'nick_name': '测试用户'})
# TODO
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file tmtoolP-0.1.32-py3-none-any.whl
.
File metadata
- Download URL: tmtoolP-0.1.32-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82e388da0a01f22f65bd9a3616d6c4707cf12e01656c67e0903ba5954fbdfb74 |
|
MD5 | a91a748ac72cd6a0ed94e4e0c1067280 |
|
BLAKE2b-256 | a612ad779d8614070a162fadf32ccabb23442d2aacc7b6c191aa4a2cb71d3a76 |