简体   繁体   English

如何从Python脚本中执行整个Javascript程序

[英]How to execute an entire Javascript program from within a Python script

So I am currently working on a project that involves the google maps API. 因此,我目前正在从事一个涉及Google Maps API的项目。 In order to display data on this, the file needs to be in a geojson format. 为了显示此数据,文件必须为geojson格式。 So far in order to accomplish this, I have been using two programs, 1 in javascript that converts a .json to a CSV, and another that converts a CSV to a geojson file, which can then be dropped on the map. 到目前为止,为了完成此任务,我一直在使用两个程序,一个是javascript中的程序,它将.json转换为CSV,另一个是将CSV转换为geojson文件,然后可以将其放置在地图上。 However, I need to make both processes seamless, therefore I am trying to write a python script that checks the format of the file, and then converts it using the above programs and outputs the file. 但是,我需要使两个进程无缝连接,因此我试图编写一个Python脚本来检查文件格式,然后使用上述程序将其转换并输出文件。 I tried to use many javascript to python converters to convert the javascript file to a python file, and even though the files were converted, I kept getting multiple errors for the past week that show the converted program not working at all and have not been able to find a way around it. 我尝试使用许多javascript至python转换器将javascript文件转换为python文件,即使文件已转换,但过去一周我仍然收到多个错误,这些错误表明转换后的程序根本无法工作,并且无法执行寻找解决方法。 I have only seen articles that discuss how to call a javascript function from within a python script, which I understand, but this program has a lot of functions and therefore I was wondering how to call the entire javascript program from within python and pass it the filename in order to achieve the end result. 我只看过一些讨论如何从python脚本中调用javascript函数的文章,据我了解,但是该程序具有很多功能,因此我想知道如何从python中调用整个javascript程序并将其传递给文件名以达到最终结果。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

While this is not exactly what you are asking for, propably using json and geojson is easier. 虽然这并不是您所要的,但使用jsongeojson更加容易。 (If you dont want to use nodejs or the like) (如果您不想使用nodejs等)

我能够编写一个转换脚本,并且现在可以正常工作,谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM