如何使用brython在python脚本中导入python模块

2024-05-16 21:13:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我打算创建一个小应用程序,使用Brython将.xlsx文件转换为.csv文件。我使用了Brython,因此我可以用python而不是javascript编写代码。然而,由于某些原因,我不能上传熊猫。 这是我的密码:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Brython Examples</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython.js" integrity="sha256-rA89wPrTJJQFWJaZveKW8jpdmC3t5F9rRkPyBjz8G04=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython_stdlib.js" integrity="sha256-Gnrw9tIjrsXcZSCh/wos5Jrpn0bNVNFJuNJI9d71TDs=" crossorigin="anonymous"></script> </head> <body onload="brython()"> <p>Click on the "Choose File" button to upload a file:</p> <form action="/action_page.php"> <input type="file" id="myFile" name="filename" > </form> <script type="text/python" > #importing pandas as pd import pandas as pd # Read and store content # of an excel file read_file = pd.read_excel ("myfile.xlsx") # Write the dataframe object # into csv file read_file.to_csv ("Test.csv", index = None, header=True) # read csv file and convert # into a dataframe object df = pd.DataFrame(pd.read_csv("Test.csv")) </script> </body> </html>

下面是我在firefox中从控制台得到的错误

this is the error that I get


Tags: 文件csvthenamereadhtmlscriptcontent