1. 定义一个print_lol函数来控制列表的缩进和写入位置 import sys """this is a new fuction, which work for a list""" def print_lol(the_list,indent=False,level=0,where=sys.stdout): """ one arguement is the_list""" for e…
1. Print them to screen man = [] other = [] try: data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':',1) line_spoken=line_spoken.strip() if role== 'Man': man.append(line_spoken) elif role == 'Other Man': oth…
以写模式打开文件:需要指定写模式,如下所示 data = open('data.out','w') 如果文件已经存在,则会清空它现有的所有内容.要追加一个文件,需要使用访问模式a,会追加到下一行. 例子:将上节中Man和Other Man说的话,分别保存到两个文件中 man = [] other = [] try: data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split…
代码如下,记得引入Oracle的dll using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OracleClient; using System.D…