我正在学习python并且正在练习练习.其中之一是编码投票系统,使用列表选择比赛的23名球员之间的最佳球员.
我正在使用Python3
.
我的代码:
players= [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
vote = 0
cont = 0
while(vote >= 0 and vote <23):
vote = input('Enter the name of the player you wish to vote for')
if (0 < vote <=24):
players[vote +1] += 1;cont +=1
else:
print('Invalid vote, try again')
Run Code Online (Sandbox Code Playgroud)
我明白了
TypeError:'str'和'int'实例之间不支持'<='
但我这里没有任何字符串,所有变量都是整数.
首先:抱歉这个副本,但其他与此问题相关的类似问题总是告诉同样的方法来解决这个问题,但确实对我不起作用.我试图将数据库从sqlite迁移到postgresql ...所以我键入:
sudo -u postgres psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
Run Code Online (Sandbox Code Playgroud)
并且输出返回:" ALTER ROLE "
但是当我键入" python manage.py migrate "时,我总是收到同样的错误:
django.db.utils.OperationalError:致命:用户"douglas"的密码验证失败
settings.py:
# Old, using mysqlite
"""
DATABASES = {
#'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#}
'default': dj_database_url.config(default='postgres://localhost:5432/postgres_db_name'),
}
"""
# New, using postgres
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'douglas_db',
'USER': 'douglas',
'PASSWORD': 'vamointer',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
Run Code Online (Sandbox Code Playgroud)
ps:当我运行' ALTER USER postgres WITH PASSWORD '时,我将相同的密码设置在settings.py中.
谢谢!