import sys
outfile = open( r'/Users/x/Desktop/myDoc.txt', 'w' )
i = 0
lis = []
n = int(raw_input("How many interviews are there? "))
while n:
i += 1
istart = raw_input("Interview Start Time: ")
iend= raw_input("Interview End Time: ")
ipeople= raw_input("What are the interviewer names: ")
itype= raw_input("What is the interview type: ")
lis.append((istart, iend, ipeople, itype))
n-=1
a = "<html><head></head><body><TABLE border=1><TR> </TR> <TR>\
<TH>Start</TH>\
<th>End</th>\
<th>People</th>\
<TH>Interview Type</TH></TR><TR ALIGN=CENTER></TR> \
<td>fff</td>dd<td>dddd</td><td>ddd</td><td>ddddd</td></TABLE></body></html>"
outfile.write(a)
outfile.close()
所以基本上这个print语句是在我的计算机上写入一个文件,但是我遇到了在这个print语句中包含另一个循环的问题,因为如果用户说有5个访谈,我需要5行,其中每行是列表中的一个元组,每列是该元组中的每一项(如果用户说有6个访谈,我需要5行)需要6行,以此类推)。有办法吗?你知道吗
这能解决你的问题吗?循环只需要创建行,不应该将文档的开始和结束放在循环中。你知道吗
可以使用range(n)代替“while n”,这样就不需要任何计数器变量。你知道吗
相关问题 更多 >
编程相关推荐