学Python制作词云过程中出现“positional argument follows keyword argument”报错,之前在在线编辑器中看了看说是问题在第12行。
from random import *
counts={}
with open("new.csv",'r',encoding='utf-8') as a:
for t in a :
t=t.strip()
code,name=t.split(",")
counts[name]=randint(30,100)
import matplotlib.pyplot as plt
from wordcloud import WordCloud
from imageio.v2 import imread
pic=imread('love.png')
wc=WordCloud(mask=pic, font_path== 'Songti.ttc',
repeat=False,
background_color='white',
max_words=100,
max_font_size=120,
min_font_size=10,
random_state=50,
scale=1 )
wc.generate_from_frequencies(counts)
plt.imshow(wc)
plt.show()
wc=WordCloud(mask=pic, font_path== 'Songti.ttc',
目测=你写成了==
A value passed to a function (or method) when calling the function. There are two kinds of argument:
keyword argument: an argument preceded by an identifier (e.g. name=) in a function call or passed as a value in a dictionary preceded by **. For example, 3 and 5 are both keyword arguments in the following calls to complex():
complex(real=3, imag=5)
complex(**{'real': 3, 'imag': 5})
positional argument: an argument that is not a keyword argument. Positional arguments can appear at the beginning of an argument list and/or be passed as elements of an iterable preceded by *. For example, 3 and 5 are both positional arguments in the following calls:
complex(3, 5)
complex(*(3, 5))
Arguments are assigned to the named local variables in a function body. See the Calls section for the rules governing this assignment. Syntactically, any expression can be used to represent an argument; the evaluated value is assigned to the local variable.
See also the parameter glossary entry, the FAQ question on the difference between arguments and parameters, and PEP 362.