擅长:python、mysql、java
<p>如果你<code>eval</code>字符串<code>"stop"</code>,你会得到那个错误,因为<code>stop</code>不是可以计算的东西。你知道吗</p>
<p>此外,您应该避免使用<code>eval</code>来评估用户输入,因为这是不安全的。你知道吗</p>
<pre><code>d={}
x=""
y=""
while x!="stop":
x=input("product?(type stop if you want to stop)")
if x!="stop":
d[x] = float(input("price?"))
print(d)
</code></pre>