如何为每个大写字母分配一个数值,然后通过字符串使用它,然后将值相加.
例如.
A = 1, B = 2, C = 3 (etc..)
string = 'ABC'
Run Code Online (Sandbox Code Playgroud)
然后返回答案6(在这种情况下).
在尝试简单的图片上传时,我收到一个错误:
TypeError at /upload/
__init__() got an unexpected keyword argument 'instance'
Run Code Online (Sandbox Code Playgroud)
以下是相关代码的信息(如果您需要更多,请告诉我们!):
# Models
class Photo(models.Model):
created_at = models.DateTimeField(auto_now_add=True, editable=False)
title = models.CharField(max_length=255)
image = models.ImageField(upload_to='photos/'+str(uuid.uuid4())+'/')
# Views
class PhotoUploadView(CreateView):
model = Photo
form_class = PhotoUploadForm
template_name = 'upload.html'
success_url = '/thanks/'
# Forms
class PhotoUploadForm(forms.Form):
image = forms.ImageField()
title = forms.CharField(max_length=255)
# Urls
urlpatterns = patterns('',
url(r'^upload/', views.PhotoUploadView.as_view()),
)
Run Code Online (Sandbox Code Playgroud) 我刚刚升级到Ubuntu 13.04(beta),当我尝试使用pip将pyside安装到Virtualenv(python 2.7.4)时出现错误:
error: Failed to locate the Python library /usr/lib/libpython2.7.so.1
Run Code Online (Sandbox Code Playgroud)
有人有主意吗?我已经尝试过以前的版本以及开发版本,但仍然没有运气.
编辑:控制台日志的post_install
(monster)tony@tonyubuntu:~/Downloads/pyside-setup$ python pyside_postinstall.py -install
PySide package found in /home/tony/Downloads/pyside-setup/PySide...
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtUiTools.so to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtCore.so to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtTest.so to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtHelp.so to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtXml.so to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtSql.so to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtGui.so to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/shiboken to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtDeclarative.so to /home/tony/Downloads/pyside-setup/PySide.
Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtSvg.so …Run Code Online (Sandbox Code Playgroud)