当前位置: 首页>>代码示例>>Python>>正文


Python Reader.getCsvDict方法代码示例

本文整理汇总了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)
开发者ID:supershdow,项目名称:SlothPal,代码行数:23,代码来源:app.py

示例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)
开发者ID:supershdow,项目名称:SlothPal,代码行数:22,代码来源:app.py

示例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)
开发者ID:supershdow,项目名称:SlothPal,代码行数:23,代码来源:app.py


注:本文中的util.Reader.getCsvDict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。