本文整理汇总了Python中util.Reader.write_file方法的典型用法代码示例。如果您正苦于以下问题:Python Reader.write_file方法的具体用法?Python Reader.write_file怎么用?Python Reader.write_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Reader
的用法示例。
在下文中一共展示了Reader.write_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendmessage
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import write_file [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)
示例2: delete
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import write_file [as 别名]
def delete():
if request.method=='GET':
reader.write_file('./util/'+session['username']+'message.txt','')
else:
if request.method=='POST':
old=reader.getCsvList('./util/'+session['username']+'message.txt')
old.pop([int(request.form.keys()[0])][0])
reader.write_file('./util/'+session['username']+'message.txt','')
old.pop()
for mess in old:
reader.write_file('./util/'+session['username']+'message.txt',mess[0]+'\n','a')
return redirect('/account/'+session['username']+'/sendmessage')
示例3: pfppic
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import write_file [as 别名]
def pfppic():
if not 'username' in session:
return redirect('/')
url=request.form['image']
reader.write_file('util/pfpimg.txt',session['username']+','+url+'\n','a')
return redirect('/account/'+session['username'])