Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过Python以HTML格式打印csv文件_Python_Csv - Fatal编程技术网

通过Python以HTML格式打印csv文件

通过Python以HTML格式打印csv文件,python,csv,Python,Csv,基本上,其想法是将注释存储在csv文件中,并在同一页面上显示它们。问题是我想让时间变得大胆,但我找不到这样做的位置。我认为主要的问题是HTML文件 从烧瓶导入烧瓶,重定向,渲染模板,请求 导入csv 从时间导入gmtime,strftime app=烧瓶(名称) @应用程序路径(“/”) def home(): 返回渲染模板('home.html') def读取文件(aFile): #读取文件并返回列表 以打开(文件“r”)作为填充: reader=csv.reader(infle) aLis

基本上,其想法是将注释存储在csv文件中,并在同一页面上显示它们。问题是我想让时间变得大胆,但我找不到这样做的位置。我认为主要的问题是HTML文件

从烧瓶导入烧瓶,重定向,渲染模板,请求
导入csv
从时间导入gmtime,strftime
app=烧瓶(名称)
@应用程序路径(“/”)
def home():
返回渲染模板('home.html')
def读取文件(aFile):
#读取文件并返回列表
以打开(文件“r”)作为填充:
reader=csv.reader(infle)
aList=[读卡器中逐行]#我认为问题就在这里
返回列表
def writeFile(列表,aFile):
#将列表写入文件
打开(文件“w”,换行=”)作为输出文件:
writer=csv.writer(输出文件)
打印(列表)
writer.writerows(列表)
返回
@app.route(“/comments”)
def comments():
#从文件中读取联系人列表
文件名='static\\comments.csv'
commentList=readFile(文件名)
返回呈现模板('comments.html',commentList=commentList)
@app.route('/addComment',methods=['POST'])
def addComment():
#从文件中读取联系人列表
文件名='static\\comments.csv'
commentList=readFile(文件名)
#在技能列表中添加一个条目
name=request.form[('name')]
日期=strftime(“%a,%d%b%Y%X”,gmtime())
#添加当前日期和时间
comment=request.form[('comment')]
新成员=[姓名、日期、评论]
commentList.append(新成员)
#将技能列表保存到文件中
writeFile(注释列表,文件名)
返回重定向(“注释”)
    {%用于commentList%中的注释。}
  • {%用于注释%中的名称}
  • {{names}}
  • {%endfor%} {%endfor%}
找到了解决方案。列表应如下所示:

    {commentList%中的行的%s}
  • {{line[0]}
    {{line[1]}
    {{{line[2]}}

  • {%endfor%}
来自W3C的W3C学校

 <ol>
 <li>Coffee</li>
 <li>Tea</li>
 <li>Milk</li>
 </ol>

 <ul>
 <li>Coffee</li>
 <li>Tea</li>
 <li>Milk</li>
 </ul> 

  • 咖啡
  • 牛奶
    • 咖啡
    • 牛奶
    对于
  • ..
    行中的中断,br标记很好,可以使用<代码>
  • <代码>
    <代码>
    <代码>
  • 。br标记是单个的。来自学校

    <li> ... <br> ... <br> ... </li>
    



  • 永远记住一条规则:在HTML内容中,最好坚持[a-z][0-9]。因此,在测试中没有花括号和百分比符号。

    应该在
  • 标记中。您实际遇到了什么问题?我想我的列表并不完美。此外,问题可能出现在.py文件中:aList=[reader中的行对行]