javascript - 如何使用 brython 在 python 脚本中导入 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 控制台得到的错误。
解决方案
推荐阅读
- angular - 如何使用 Socket.io 将实时音频流从 Angular 发送到 python 烧瓶服务器?
- python - Python 包可以创建一个通过多个自身实例持久存在的变量吗?
- c# - .NET Core:当 ApiController 缩短管道时访问错误请求的请求数据
- javascript - 我的媒体文件的路径在 django 项目中不起作用
- ruby - The "realmRoles" parameter is ignored when adding a user via the Keycloak API
- typo3 - 重定向后不显示 Flash 消息
- python - 如何相互减去两个列表列表?
- php - 在 PHP 中使用 xpath 查询 XML
- wpf - 将“SelectedItems”依赖属性绑定到 ViewModel 属性不起作用
- c# - 用一个或多个“选择”命令填充数据表