所以我有這個定義,基本上只保存用戶的個人資料。 目前我有1個成功消息,我想在多個成功和錯誤消息之間旋轉:value = {'result': 'success', 'message': '...'}
如何在Python/Pyramid中使用多個隨機字符串?
你會怎麼做呢?
@view_config(route_name="profile", request_method='POST')
def save_profile(self):
try:
json = self.request.json_body
first_name = str(json['firstName'])
last_name = str(json['lastName'])
organization = str(json['organization'])
title = str(json['title'])
phones = (json['phones'])
emails = (json['emails'])
self.profiles.update(firstName=first_name, lastName=last_name, organization=organization, title=title, emails=emails, phones=phones)
value = {'result': 'success', 'message': "Saved! Worry not, nothing sent to the NSA... as far as we know"}
except Exception, err:
print err
value = {'result': 'error', 'message': 'The internets are clogged up, our monkeys are checking it out'}
如何將消息粘貼到列表中,然後從該列表中隨機選擇?你也不需要'(json ['phones'])'和類似的括號。 –