本文整理汇总了Python中util.Reader.getCsvDict方法的典型用法代码示例。如果您正苦于以下问题:Python Reader.getCsvDict方法的具体用法?Python Reader.getCsvDict怎么用?Python Reader.getCsvDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Reader
的用法示例。
在下文中一共展示了Reader.getCsvDict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: account
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import getCsvDict [as 别名]
def account(usr):
if not 'username' in session:
return redirect('/')
user_list = reader.getCsvDict("./util/credentials.txt")
if not usr in user_list.keys():
return render_template("error.html",error = "The username you have provided does not exist.",globe=globe)
img=reader.getCsvDict('util/pfpimg.txt')
userinfo=user_list[usr]
gender=userinfo[1]
Countryin=userinfo[2]
Target=userinfo[3]
url='/account/'+session['username']+'/settings'
if session['username']==usr:
own=True
else:
own=False
if usr in img:
img=img[usr][0]
else:
img='http://s3-static-ak.buzzfed.com/static/2014-07/14/12/campaign_images/webdr09/meet-lunita-the-cutest-baby-sloth-on-planet-earth-2-9684-1405357019-4_big.jpg'
return render_template("account.html",user = usr,user_list = user_list,globe=globe, img=img,gender=gender,Country=Countryin,target=Target,own=own,dir=url)
示例2: sendmessage
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import getCsvDict [as 别名]
def sendmessage(usr):
reader.write_file('./util/'+usr+'message.txt','','a')
url='/account/'+usr+'/sendmessage'
if not 'username' in session:
return redirect('/')
user_list=reader.getCsvDict('./util/credentials.txt').keys()
messages=reader.read_file('./util/'+usr+'message.txt')
messages=messages.split('\n')
messages.pop(-1)
if messages==['']:
out=False
else:
out=True
if request.method=='GET':
return render_template('messages.html',dir=url,messages=messages,out=out)
elif request.method=='POST':
if not request.form['recipient'] in user_list:
return render_template('messages.html',dir=url,messages=messages,out=out)
mess.sendMessage(session['username'],request.form['recipient'],request.form['message'])
return redirect(url)
示例3: home
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import getCsvDict [as 别名]
def home():
if not 'username' in session:
return redirect('/')
user_list=reader.getCsvDict('./util/credentials.txt')
current=user_list[session['username']][3]
del user_list[session['username']]
g=0
rect=False
rec=[]
for i in user_list.keys():
if user_list[i]==current:
rec.append(user_list.items()[g][0])
rect=True
g+=1
if rec!=[]:
rec=choice(rec)
usr=session['username']
url='/account/'+usr+'/sendmessage'
if not rect:
return render_template('home.html',user=session['username'],prof='/account/'+session['username'],recomended=rect,dir=url)
return render_template('home.html',user=session['username'],prof='/account/'+session['username'],rec='/account/'+rec,recomended=rect,dir=url)