Skip to main content

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

Metadata

Release files for tmtoolP 0.1.32

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for tmtoolP 0.1.32
File Interpreter ABI Platform Actions
tmtoolP-0.1.32-py3-none-any.whl Python 3 none any Details for tmtoolP-0.1.32-py3-none-any.whl

Release files / tmtoolP-0.1.32-py3-none-any.whl

Download URL tmtoolP-0.1.32-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82e388da0a01f22f65bd9a3616d6c4707cf12e01656c67e0903ba5954fbdfb74
BLAKE2b-256 checksum
How to use checksums
a612ad779d8614070a162fadf32ccabb23442d2aacc7b6c191aa4a2cb71d3a76
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for tmtoolP 0.1.32

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.32 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page