摘要:
在python的编写过程中,经常出现中文字符,英文字符。如何保证 空格 为中文字符 template_t= “{0:^10}\t {1:{3}^30}\t{2:^20}” tmplate_t.format(itemt[1],item[2],item[3],chr(12288)) 其中 chr(122 阅读全文
随笔分类 - Python
python中excel 中的读写,追加操作。仅供参考。没有时间整理
2021-03-14 10:01 by ttym88m, 296 阅读, 收藏,
摘要:
import xlrdimport xlsxwriter# work_book = xlrd.open_workbook("12010219801201332X王桂玉.xlsx")# sheet_names = work_book.sheet_names()# print(sheet_names)# 阅读全文
python 使用事务
2021-03-11 20:49 by ttym88m, 156 阅读, 收藏,
摘要:
def mysql_test(request): try: with transaction.atomic(): # 一系列对数据库的操作 pass except Exception: # 最好具体的错误类型,捕捉具体的错误 pass 好了,上面就是关于django中使用事务的方式 不过这里还是得提 阅读全文
Python中 list 等增加序号的问题
2021-03-10 16:40 by ttym88m, 269 阅读, 收藏,
摘要:
在python中,循环某些类型数据,需要增加序号的功能,便于统计和计算。可以转换为enumerate 格式进行转换,具体如下:listall = os.listdir(finaldir)addothers = str(datetime.datetime.now().strftime("%Y%m%d% 阅读全文
Python Django 中,如何开启sql语句的执行情况
2021-03-10 16:34 by ttym88m, 105 阅读, 收藏,
摘要:
在settings.py中 增加 LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'simple': { 'format': '[%(asctime)s] %(message)s' }, }, 阅读全文
django 分页加序号
2021-03-08 15:13 by ttym88m, 207 阅读, 收藏,
摘要:
1.建立一个类 mypage.py class Pagination(object): def __init__(self, current_page, all_count, per_page_num=10, pager_count=11): """ 封装分页相关数据 :param current_ 阅读全文
Excel 日期格式读入到python 的xlrd 模块中。转换格式
2021-03-07 17:38 by ttym88m, 194 阅读, 收藏,
摘要:
asdf = xlrd.xldate.xldate_as_datetime(date,0) #2019-06-01 17:36:46 datetime.datetime sd = xlrd.xldate.xldate_as_datetime(date,0).__format__('%Y-%m-%d' 阅读全文
python 使用pymysql上传excel数据
2021-02-27 22:09 by ttym88m, 257 阅读, 收藏,
摘要:
from django.shortcuts import render, HttpResponsefrom Day72bbs.settings import MEDIA_ROOTfrom docxtpl import DocxTemplateimport osimport xlrd MEDIA_RO 阅读全文
python 批量打印word文档
2021-02-27 17:17 by ttym88m, 392 阅读, 收藏,
摘要:
1.pip install pypiwin32 安装模块 2.创建类:printers.py import tempfileimport win32apiimport win32printdef printer_loading(filename): open(filename, "r") win32 阅读全文
python 批量打印word文档
2021-02-27 15:57 by ttym88m, 753 阅读, 收藏,
摘要:
1.在settings.py 文件中。加入如下语句 MEDIA_URL='/doctemplates/' #模板的路径名称MEDIA_ROOT = os.path.join(BASE_DIR, 'doctemplates')#模板的路径2.在工程下面建立 doctemplates 文件夹。用于存放模 阅读全文
Python Django 使用数据库中的视图
2021-02-27 15:38 by ttym88m, 293 阅读, 收藏,
摘要:
1.在AppDatabaseViews项目中,创建 mysqlviews.py模块。模块中的内容如下:from AppDatabaseViews.models import * # #AppDatabaseViews 是项目工程 class viewsbookandpublish(models.Mo 阅读全文
清除chrome的缓存
2021-02-24 08:20 by ttym88m, 288 阅读, 收藏,
摘要:
1。在网页的空白处点击 右键 ->检查 -> 设置齿轮 按钮-> network ->Disable cache 勾选。勾选后就可以去除缓存了。 阅读全文
浙公网安备 33010602011771号