擅长:python、mysql、java
<p>如果满足条件,则使用<code>while True</code>循环和<code>break</code>。你知道吗</p>
<pre><code>d={}
while True:
product = input("product?(type stop if you want to stop)")
if product == 'stop':
break
price = float(input("its price?"))
d[product] = price
print(d)
</code></pre>
<p>我为变量使用了更有意义的名称,根据<a href="https://www.python.org/dev/peps/pep-0008/" rel="nofollow noreferrer">Style Guide for Python Code</a>格式化代码,并删除了<a href="https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html" rel="nofollow noreferrer">^{<cd3>}</a>的危险用法。你知道吗</p>