我用python编写了读取CSV文件的代码。现在,我想从javascript或HTML
运行该python代码这是python代码
with open('C:\\Users\\Desktop\\Summer.csv') as csvDataFile:
csvReader = csv.reader(csvDataFile)
for row in csvReader:
print(row)
这是html和javascript代码
$.ajax({
url: "C:\\Users\\Pictures\\test.py",
success: function(response) {
// here you do whatever you want with the response variable
}
});
}
答案 0 :(得分:0)
with open('C:\\Users\\Desktop\\Summer.csv') as csvDataFile:
csvReader = csv.reader(csvDataFile)
for row in csvReader:
print(row)
将此代码绑定到py文件中的函数中
$.ajax({
url: "..\test.py\somefunctionName",
success: function(response) {
// here you do whatever you want with the response variable
}
});
}
使用url参数调用该函数,您就很好了