Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在javascript代码中使用python列表?_Javascript_Python 3.x_Selenium - Fatal编程技术网

如何在javascript代码中使用python列表?

如何在javascript代码中使用python列表?,javascript,python-3.x,selenium,Javascript,Python 3.x,Selenium,如何在javascript代码中使用python列表 stream_id = 4000 # add stream sources list a_file = open("C:/Users/Unknown/Documents/Selenium/stream_source.txt", "r") stream_sources_list = [] for line in a_file: stripped_line = line.strip() stre

如何在javascript代码中使用python列表

stream_id = 4000

# add stream sources list
a_file = open("C:/Users/Unknown/Documents/Selenium/stream_source.txt", "r")

stream_sources_list = []
for line in a_file:
  stripped_line = line.strip()
  stream_source_line_list = stripped_line.split()
  stream_sources_list.append(stream_source_line_list)

a_file.close()

print("stream_sources:", len(stream_sources_list))

    while listposition < len(stream_sources_list):

        # navigate
        driver.get("http://192.168.94.128:25500/stream.php?id={}".format(stream_id))

        driver.execute_script(f"document.getElementById('stream_source').setAttribute('value', '{stream_sources_list[listposition]}');")

        stream_id = stream_id + 1
        listposition = listposition + 1
使用node.js子进程 子进程。spawn():

这里有一个例子
.

您能提供此错误的完整回溯吗?以及您实际调用这个
驱动程序的代码。执行脚本()
函数?您共享的内容似乎只包括您将文件中的项目读取到列表中,然后打印该列表的长度。由于某些原因,我无法发布完整的代码,它说您的帖子主要是代码,所以我试着最小化代码,并且已经解决了问题所在。也许如果你添加一些更详细地描述你的问题的措辞,你就能够做到这一点。完整的回溯会使这更容易理解。我想做的是,我有一个列表,在这个列表中有项目,我去链接并登录,然后有输入,而不是键入,我用列表中的项目设置每个输入的值,这是一个循环,可以对列表中的每一项执行此操作。必须有代码和回溯。当前的这个问题是不可重复的,没有回溯就不清楚实际错误是什么,如果问题是在您使用
selenium
的方式中,如果没有看到您编写的代码就无法诊断。
driver.execute_script(f"document.getElementById('stream_source').setAttribute('value', '{stream_sources_list[listposition]}');")