This commit is contained in:
512song committed 2024-04-29 18:35:09 +08:00
1 parent ad11e12657
commit fc007608ca
2 files changed
+91 -116

No files matched your search

+88 -17
View File
@@ -140,6 +140,59 @@
"print(path)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 新建二维码图片pdf文件"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {
"execution": {
"iopub.execute_input": "2024-04-17T10:26:43.968709Z",
"iopub.status.busy": "2024-04-17T10:26:43.968240Z",
"iopub.status.idle": "2024-04-17T10:26:44.078424Z",
"shell.execute_reply": "2024-04-17T10:26:44.077901Z",
"shell.execute_reply.started": "2024-04-17T10:26:43.968671Z"
},
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"''"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from fpdf import FPDF\n",
"import warnings\n",
"\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
"pdf = FPDF()\n",
"# compression is not yet supported in py3k version\n",
"pdf.compress = False\n",
"pdf.add_page()\n",
"# Unicode is not yet supported in the py3k version; use windows-1252 standard font\n",
"pdf.add_font('ali-regular', '', r\"fonts/AlibabaPuHuiTi-2-55-Regular.ttf\", uni=True)\n",
"pdf.set_font('ali-regular', '', 14) \n",
"#pdf.ln(10)\n",
"#pdf.write(5, '欢迎')\n",
"pdf.text(20,280,'欢迎来到中国,中国欢迎您!')\n",
"pdf.image(\"data/water/平和体质.png\", 50, 250,20)\n",
"\n",
"pdf.output('py3k.pdf', 'F')"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -308,6 +361,39 @@
"print('ok!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 整理文件"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {
"execution": {
"iopub.execute_input": "2024-04-29T10:30:55.619317Z",
"iopub.status.busy": "2024-04-29T10:30:55.618845Z",
"iopub.status.idle": "2024-04-29T10:30:55.643351Z",
"shell.execute_reply": "2024-04-29T10:30:55.642405Z",
"shell.execute_reply.started": "2024-04-29T10:30:55.619280Z"
},
"tags": []
},
"outputs": [],
"source": [
"import re\n",
"file_name = 'file/三国演义.txt'\n",
"list1 = []\n",
"with open(file_name,'r') as fl:\n",
" for l in fl:\n",
" if len(l.strip())>0:\n",
" list1.append(l.strip()+'\\n')\n",
"with open('file/三国演义_new.txt','w') as fl1:\n",
" fl1.writelines(list1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -364,26 +450,11 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-29T10:35:05.758138Z",
"iopub.status.busy": "2023-05-29T10:35:05.757286Z",
"iopub.status.idle": "2023-05-29T10:35:05.830677Z",
"shell.execute_reply": "2023-05-29T10:35:05.829666Z",
"shell.execute_reply.started": "2023-05-29T10:35:05.758096Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"outputs": [],
"source": [
"import yaml\n",
"import json\n",