Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
testCode.py 2.17 KB
Copy Edit Raw Blame History
linght authored 2025年07月21日 22:48 +08:00 . 增加 sftp
from datetime import datetime
from commonLib.jsonHelper.jsonHelper import JsonHelper
from loguru import logger
from reportlab.lib import colors
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
def testLog():
logger.info("初始化成功2222222222")
logger.warning("示例警3333333告")
logger.error("错误信息4444444444")
def test_json():
data = {"name": "绅纺西", "port": 12345, "list": [1, 2, 3], "nested": {"a": 10, "b": True}}
# 编码为字符串
json_str = JsonHelper.encode(data)
logger.info("编码后JSON字符串:")
logger.info(json_str)
# 解析回对象
parsed = JsonHelper.decode(json_str)
logger.info("解析后Python对象:")
logger.info(parsed)
# 写入文件
JsonHelper.write_file(data, "test.json")
# 从文件读取
read_back = JsonHelper.read_file("test.json")
logger.info("从文件读回的内容:")
logger.info(read_back)
def generateTestReport(filePath="TestReport.pdf"):
c = canvas.Canvas(filePath, pagesize=A4)
width, height = A4
y = height - 40 * mm # 初始Y坐标
lineSpacing = 12 * mm
# 1. 居中标题
c.setFont("Helvetica-Bold", 18)
c.drawCentredString(width / 2, y, "xxx测试报告")
y -= lineSpacing * 2
# 设置字体
c.setFont("Helvetica", 12)
# 2. 测试项1 —— 通过(绿色)
c.setFillColor(colors.black)
c.drawString(30 * mm, y, "测试项1")
c.setFillColor(colors.green)
c.drawString(width - 60 * mm, y, "通过")
y -= lineSpacing
# 3. 测试项2 —— 失败(红色)
c.setFillColor(colors.black)
c.drawString(30 * mm, y, "测试项2")
c.setFillColor(colors.red)
c.drawString(width - 60 * mm, y, "失败")
y -= lineSpacing
# 4. 测试时间
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
c.setFillColor(colors.black)
c.drawString(30 * mm, y, f"测试时间: {now}")
y -= lineSpacing
# 5. 测试结论
c.drawString(30 * mm, y, "测试结论: 通过")
c.save()
logger.info(f"PDF saved to {filePath}")
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

pythonCode
No labels
GPL-3.0
Use GPL-3.0
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/linght/python-code.git
git@gitee.com:linght/python-code.git
linght
python-code
pythonCode
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /