我在使用Python将字符串更改为大写时遇到问题.在我的研究中,我得到string.ascii_uppercase
但它不起作用.
以下代码:
>>s = 'sdsd'
>>s.ascii_uppercase
Run Code Online (Sandbox Code Playgroud)
给出此错误消息:
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'str' object has no attribute 'ascii_uppercase'
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何在Python中将字符串转换为大写?
如何通过按日期降低django中的查询集来订购?
Reserved.objects.all().filter(client=client_id).order_by('check_in')
Run Code Online (Sandbox Code Playgroud)
我只想过滤掉所有保留的check_in日期.
我正在使用ubuntu 12.04而我正在尝试使用安装virtualenv,但突然间我遇到了这个错误.
samuel@sampc:~$ pip install virtualenv
Downloading/unpacking virtualenv
Running setup.py egg_info for package virtualenv
warning: no previously-included files matching '*' found under directory 'docs/_templates'
warning: no previously-included files matching '*' found under directory 'docs/_build'
Installing collected packages: virtualenv
Running setup.py install for virtualenv
error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': Permission denied
Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/samuel/build/virtualenv/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-Z2v_fR-record/install-record.txt:
running install
running build
running build_py
running install_lib
creating /usr/local/lib/python2.7/dist-packages/virtualenv_support
error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': …
Run Code Online (Sandbox Code Playgroud) 如何在python的datetime中获取日期名称(例如:星期一,星期二,星期三,星期四,星期五,星期六和星期日)?...
这是我的handlers.py中的代码
from django.utils.xmlutils import SimplerXMLGenerator
from piston.handler import BaseHandler
from booking.models import *
from django.db.models import *
from piston.utils import rc, require_mime, require_extended, validate
import datetime
class BookingHandler(BaseHandler):
allowed_method = ('GET', 'POST', 'PUT', 'DELETE')
fields = ('id', 'date_select', 'product_name', 'quantity', 'price','totalcost', 'first_name', 'last_name', 'contact', 'product')
model = Booking
def read(self, request, id, date_select):
if not self.has_model():
return rc.NOT_IMPLEMENTED
try:
prod = Product.objects.get(id=id)
prod_quantity = prod.quantity
merge = []
checkDateExist = Booking.objects.filter(date_select=date_select)
if checkDateExist.exists():
entered_date = Booking.objects.values('date_select').distinct('date_select').filter(date_select=date_select)[0]['date_select']
else: …
Run Code Online (Sandbox Code Playgroud) 我正在开发页面,现在我的css风格我有这行代码
.flex-control-thumbs li {
width: 25%;
float: left;
margin: 0;
}
Run Code Online (Sandbox Code Playgroud)
对于我的网页.现在,我的一些页面不需要这一行
width: 25%;
float: left;
Run Code Online (Sandbox Code Playgroud)
我可以在页面的内部css中覆盖它,这会导致原始行为被忽略吗?
我在windows7上使用Django 1.3.7和python 2.7.6当我在这行代码中执行manage.py时遇到错误
import shutil, sys, virtualenv, subprocess
Run Code Online (Sandbox Code Playgroud)
运行它,我得到了这个错误
C:\Django-Proj\>python manage.py update_ve
Traceback (most recent call last):
File "manage.py", line 4, in <module>
import shutil, sys, virtualenv, subprocess
ImportError: No module named virtualenv
Run Code Online (Sandbox Code Playgroud)
有没有人对我的案子有所了解?
我怎么能在django的查询集中有一个子查询?例如,如果我有:
select name, age from person, employee where person.id = employee.id and
employee.id in (select id from employee where employee.company = 'Private')
Run Code Online (Sandbox Code Playgroud)
这就是我所做的.
Person.objects.value('name', 'age')
Employee.objects.filter(company='Private')
Run Code Online (Sandbox Code Playgroud)
但它没有工作,因为它返回两个输出...
我正在使用eclipse junno为我的IDE开发android程序.
我的问题就像这样: 用户操作正在等待"构建工作区"
为什么会这样,我该如何解决?关于这个案子我已经等了很多时间.
现在它看起来像这样.
我在我的模板中有这个代码:
{% for email in emails %}
{%if email%}
<input type="checkbox" name="email" value="{{email}}" /> {{email}}<br />
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
所以模板中的输出是:
email1@sample.com
email2@sample.com
email3@sample.com
...
Run Code Online (Sandbox Code Playgroud)
在我看来,我打印了我的请求.关于这个.
print request.POST
print request.POST['email']
for email in request.POST['email']:
print email
Run Code Online (Sandbox Code Playgroud)
我有这个输出:
<QueryDict: {u'email': [u'email1@sample.com', u'email2@sample.com', u'email3@sample.com'], ..., u'csrfmiddlewaretoken': [u'05e5bdb542c3be7515b87e8160c347a0', u'05e5bdb542c3be7515b87e8160c347a0']}>
email3@sample.com
e
m
a
i
l
3
@
s
a
m
p
l
e
.
c
o
m
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何在我的观点中获取电子邮件列表?我希望输出会像这样..
email1@sample.com
email2@sample.com
email3@sample.com
...
Run Code Online (Sandbox Code Playgroud) 我正在制作一个打开并读取文件的程序.这是我的代码:
import java.io.*;
public class FileRead{
public static void main(String[] args){
try{
File file = new File("hello.txt");
System.out.println(file.getCanonicalPath());
FileInputStream ft = new FileInputStream(file);
DataInputStream in = new DataInputStream(ft);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strline;
while((strline = br.readLine()) != null){
System.out.println(strline);
}
in.close();
}catch(Exception e){
System.err.println("Error: " + e.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时,我收到这个错误:
C:\Users\User\Documents\Workspace\FileRead\hello.txt
Error: hello.txt (The system cannot find the file specified)
Run Code Online (Sandbox Code Playgroud)
我FileRead.java
和hello.txt
在同一目录中的位置可以找到:
C:\Users\User\Documents\Workspace\FileRead
Run Code Online (Sandbox Code Playgroud)
我想知道我做错了什么?