str1 = 'aldjflaksdjfoaivhoadsvhaiouh'
def s(x):
num = x.index('a') + x.index('e') + x.index('i') + x.index('o') + x.index('u')
return num
print "Number of vowels:" + s(str1)
str1 = 'aldjflaksdjfoaivhoadsvhaiouh'
def s(x):
num=0
for n in x:
if (n=='a' or n=='e' or n=='i' or n=='o' or n=='u'):
num = num+1
return num
print "Number of vowels:" , s(str1)
str1 = 'aldjflaksdjfoaivhoadsvhaiouh'
print str1.count('a') + str1.count('e') + str1.count('i') + str1.count('o') \
+ str1.count('u')
s= 'bobobobxboboobcobooo'
print "Number of times 'bob' occurs is:" + s.count('bob')
s= 'bobobobxboboobcobooo'
print "Number of times 'bob' occurs is: " + str(s.count('bob'))
hello i want to use geos for one project.
i have install successful gdal and leaflet and djgeojson.
i try to open manage.py and show me that error :
point import sqlite3_create_function_v2 not
find in library dynamic connection c:programs files (x86)\GDAL\spatialite.dll(i have this dll in my files)
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'leaflet',
'djgeojson'
if i remove leaflet from INSTALLED_APPS then dont show me error,
i have windows 10 ,python 2.7.11 32 bit
any idea ?i need help
Hi, everyone! Here is my problem: i have an HTML template and standalone JS script. Inside script i do AJAX requests to my app, so to not to harcode urls i want to use django's{% url %}
, but i cannot simply use it in JS.
I have found one solution: generate urls in HTML in <script>
and store them in var, but my urls have parameters, so i have to do something like
var url = "{% url 'someapp:somename' param='99999' %}";
in HTML (where '99999' is magic number), and
url.replace('99999', param);
in JS. But i think its quite ugly :worried:
So, what is the best way to do it?
Thanks!
str1 = 'aldjflaksdjfoaivhoadsvhaiouh'
chars = 'aeiou'
if any((c in chars) for c in str1):
num += 1
down vote
favorite
I have a shopping cart rendered by view method A, I want to get the details in the cart to be submitted to the pesapal api. I'm using the same method as the sandbox app, PaymentView. The shopping cart has a checkout button which is intended to submit the data to the api. The Sandbox method simlpy gets the data as a dictionary (order_info) and feeds to the url, thus when I open the template, the api's iframe dictates I am withrawing the amout specified in the dictionary. How can I submit data via the cart?
class PaymentView(TemplateView, PaymentRequestMixin):
template_name = 'payment/payment.html'
# how the sandbox app submits data to api:
def get_context_data(self, **kwargs):
ctx = super(PaymentView, self).get_context_data(**kwargs)
order_info = {
'amount': '1000',
'description': 'Ad Payment for adlink',
'reference': 2,
'email': 'you@email.com'
}
ctx['pesapal_url'] = self.get_payment_url(**order_info)
return ctx
def show_cart(request, template_name="payment/cart.html"):
if request.method == 'POST':
data = {}
postdata = data
postdata = request.POST.copy()
if postdata['submit'] == 'Remove':
cart.remove_from_cart(request)
if postdata['submit'] == 'Update':
cart.update_cart(request)
if postdata['submit'] == 'Checkout':
# submission to api should occur here
cart_items = cart.get_cart_items(request)
cart_subtotal = cart.cart_subtotal(request)
return render_to_response(template_name, locals(), context_instance=RequestContext(request))