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 )
This is code I write to count the frequency of the words, and at the first line, there is 'import first': first is the module that I want to use turtle. To say, I want to count the frequency here, and apply the module'first' to draw histogram using turtle module. The histogram that reflect the frequency! Hope other people understand it... Anyway, to do this, I have to use that variable 'bigword' in first.py, but I don't know how to connect these two files.
if for example your first.py contains a variable called b, you can call it from your 'main' file like this:
import first
bigword = first.b
same goes the other way around. So from your first.py file you can call:
import [filename-containing-bigword]
bigword = [filename-containing-bigword].bigword
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.