#!/usr/bin/python #coding=UTF-8 #FileName:search.py #文件搜索 import os; import sys; returnList = []; def search_file_in_dir(fileName, dirName): global returnList; #print dirName; if not os.path.isdir(dirName): sys.exit('directory does not exist.(%s)'%(d…
本章所用test.txt文件可以在( [Python 从入门到放弃] 6. 文件与异常(一))找到并自行创建 现在有个需求,对test.txt中的文本内容进行修改: (1)将期间的‘:’改为‘ said:’ (2)将修改后的内容以覆盖的形式重新写入到该文件 1.步骤分析: 在( [Python 从入门到放弃] 6. 文件与异常(一))我们提到 在进行文件操作时,需要逐行处理,可以使用迭代器 因为test.txt的内容是: Man:Is this the right room for an arg…
常规的模板渲染 from django.db import models # Create your models here. class ArticalType(models.Model): caption = models.CharField(max_length=16) class Category(models.Model): caption = models.CharField(max_length=16) class Artical(models.Model): title = mo…