我试图在Python中创建一个简单的密码存储程序,它看起来很简单,所以我想知道我是否使用搁置错误.
我有主.py文件:
import shelve
passwords = shelve.open('./passwords_dict.py')
choice = raw_input("Add password (a) or choose site (c)?")
if choice[0] == 'a':
site_key = raw_input("Add for which site? ").lower()
userpass = raw_input("Add any info such as username, email, or passwords: ")
passwords[site_key] = userpass
else:
site = raw_input("Which site? ").lower()
if site in passwords:
print "Info for " + site + ": " + passwords[site]
else:
print site, "doesn't seem to exist!"
print "Done!"
passwords.close()
Run Code Online (Sandbox Code Playgroud)
而另一个文件passwords_dict.py只是一个空字典.
但是当我尝试运行该程序时,我收到此错误:
Traceback (most recent call last): …Run Code Online (Sandbox Code Playgroud) 我在Flask中有一个单页网站,底部有联系表。如何防止浏览器在提交时跳到页面顶部?我不能使用return false,因为实际上没有发生任何显式的JavaScript。我正在使用Flask的WTForms。
<section id="contact">
<h2 class='contact'>Contact</h2>
{% if success %}
<p>Thanks for your message!</p>
{% else %}
{% for message in form.name.errors %}
<div class="flash">{{ message }}</div>
{% endfor %}
{% for message in form.email.errors %}
<div class="flash">{{ message }}</div>
{% endfor %}
{% for message in form.subject.errors %}
<div class="flash">{{ message }}</div>
{% endfor %}
{% for message in form.message.errors %}
<div class="flash">{{ message }}</div>
{% endfor %}
<form id="contactform" action="{{ url_for('contact') }}" method=post>
{{ form.hidden_tag() }}
## "autofocus=true" …Run Code Online (Sandbox Code Playgroud)