Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.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
Python 如何使用turtle模块绘制直方图?_Python_Histogram_Turtle Graphics - Fatal编程技术网

Python 如何使用turtle模块绘制直方图?

Python 如何使用turtle模块绘制直方图?,python,histogram,turtle-graphics,Python,Histogram,Turtle Graphics,这是我用来计算单词频率的代码,在第一行,有“import first”:第一行是我想使用的模块。也就是说,我想在这里计算频率,并应用模块“first”使用turtle模块绘制直方图。反映频率的直方图!希望其他人能理解。。。 无论如何,要做到这一点,我必须在first.py中使用变量“bigword”,但我不知道如何连接这两个文件 例如,如果first.py包含一个名为b的变量,则可以从“main”文件调用它,如下所示: import first counts = dict() with op

这是我用来计算单词频率的代码,在第一行,有“import first”:第一行是我想使用的模块。也就是说,我想在这里计算频率,并应用模块“first”使用turtle模块绘制直方图。反映频率的直方图!希望其他人能理解。。。
无论如何,要做到这一点,我必须在first.py中使用变量“bigword”,但我不知道如何连接这两个文件

例如,如果first.py包含一个名为b的变量,则可以从“main”文件调用它,如下所示:

import first

counts = dict()

with open('junior.txt') as handle:
    for line in handle:
        words = line.split()
        for word in words:
            counts[word] = counts.get(word, 0) + 1

    print(counts)

bigcount = None
bigword = None

for word, count in counts.items():
    if bigcount is None or count > bigcount:
        bigword = word
        bigcount = count

first.show_histogram( vk_list )
反之亦然。因此,您可以从第一个.py文件调用:

import first
bigword = first.b

如果这有帮助,让我知道!
import [filename-containing-bigword]
bigword = [filename-containing-bigword].bigword