分析PythonAnywhere

时间:2015-12-03 19:43:09

标签: pythonanywhere

我的python代码在我的计算机上运行得非常好,只是我的笔记本电脑非常慢。我想上传代码并在PythonAnywhere上运行它。 (甚至不确定这是否是最适合的资源,但它相对容易使用!)

我已成功将一些文件和我的代码上传到我的主目录,代码运行正常。但由于我有很多要分析的文件,我已经上传了一个zip文件,成功地将其上传(到home / myname / part1)并将我的python代码保存到同一目录中。但是,当我尝试在该目录中运行我的代码时,它不起作用。事实上,代码不会返回任何错误,它分析2个空白文件而不是我上传的100个左右。然后它会停止并退出,好像工作已经完成。

任何想法为什么? TIA!

如果这很重要,这里是代码的精简版本("分析"不是命令,而是代表更多的分析线,所有这些都在我的计算机上正常运行):

import csv, re
from string import punctuation
import glob, io

csvfile=open("test.csv", "w", newline='', encoding='cp850', errors='replace')
writer=csv.writer(csvfile)
for filename in glob.glob('*.txt'):

    ###Open files and arrange them so that they are ready for pre-processing
    with open(filename, encoding='utf-8', errors='ignore') as f:

      analysis

      output=zip(file1, file_name, more_date)
      writer=csv.writer(open('test.csv','a',newline='', encoding='cp850', errors='replace'))
      writer.writerows(output)
      csvfile.flush()

1 个答案:

答案 0 :(得分:0)

我的猜测是,您没有处理您认为自己正在处理的文件。打印glob的结果,以便验证您是否在您认为自己的目录中工作。