我正在尝试使用jinja2构建我的第一个GAE应用程序.在克服了十几个小错误之后,现在我坚持这个:
Traceback(最近一次调用最后一次):
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1536, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1530, in __call__
rv = self.router.dispatch(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1102, in __call__
return handler.dispatch()
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "C:\Users\CG\Documents\udacity\HiMon\main.py", line 31, in get
template = jinja_environment.get_template('index.html')
File …Run Code Online (Sandbox Code Playgroud) 我需要复制 Google 文档的内容,并将其附加到另一个文档。如果我使用这样的东西:
newDoc.getBody().appendParagraph(template.getText());
...我得到了文本,但丢失了原始文件中的格式。(粗体、斜体等)
如何将内容和格式复制到新文档?是否可以将所有内容分配给一个变量,然后将其复制/粘贴到新文档中?
没有办法在 Google 文档中只共享一个电子表格中的一张。因此,您必须共享整个电子表格。因此,我正在考虑编写一个脚本来同步两张工作表(每个工作表都在不同的电子表格中)。我想使用一个函数来获取行作为数组来做到这一点。有没有更好的策略来做到这一点?
我有这个问题:我下载了一个excell文件,然后将其上传(将其转换为Google电子表格格式),并且必须将其调整为一种可以与脚本一起使用的结构。为此,我必须删除excell文件的几行和几列(excell标头中有一些图片和多余的行)。因此,我正在编写一个脚本来自动执行此任务。但是,当我运行此脚本时,要删除前22行:
function onOpen() {
var menuEntries = [{name: "Format this sheet", functionName: "format"}];
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.addMenu("My scripts", menuEntries);
}
function format() {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.deleteRows(0, 22);
// sheet.deleteColumns(columnPosition, howMany)
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Those rows are out of bounds. (电子表格有400多行)
我该如何解决?
有没有一种方法可以使用addMenu(name, subMenus)其他方法将子菜单放入Google电子表格的子菜单中?
自2015年4月20日起,DocsList服务"服务不再起作用".我有这个函数这个函数使用了docsList服务:
/**
* Duplicates a Google Apps doc
*
* @return a new document with a given name from the orignal
**/
function createDuplicateDocument(sourceId, name) {
var source = DocsList.getFileById(sourceId);
var newFile = source.makeCopy(name);
var targetFolder = DocsList.getFolderById(TARGET_FOLDER);
newFile.addToFolder(targetFolder);
return DocumentApp.openById(newFile.getId());
}
Run Code Online (Sandbox Code Playgroud)
如何DocsList在此createDuplicateDocument功能中更换服务?
我是一个蟒蛇新手,我正在尝试逐步建立一个应用程序,我在课堂上已经教过了,但我得到了"405 Method Not Allowed"错误.
教授在这里做了什么:

我在这做了什么:

有人能指出我在下面的代码中是什么导致此错误"405 Method Not Allowed"?我看不出我做了什么和教授教的内容之间的区别.缩进也可以(这里是main.py文件https://docs.google.com/open?id=0B8TXLR_e14aCVDFfdlpYSU9DNDg).
在此先感谢您的帮助!
这是我的代码:
form= """
<html>
<head>
<title>Unit 2 Rot 13</title>
</head>
<body>
<h2>Enter some text to ROT13:</h2>
<form method="post" action="/rot13">
<textarea name="text"
style="height: 100px; width: 400px;"></textarea>
<br>
<input type="submit">
</form>
</body>
</html> """
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write(form)
class Rot13Handler(webapp2.RequestHandler):
def post(self):
text = self.request.get("text")
self.response.out.write(text)
app = webapp2.WSGIApplication([('/', MainHandler), ('/rot13', Rot13Handler)],
debug=True)
Run Code Online (Sandbox Code Playgroud) 这行代码:
geted_nickname = user.nickname()
Run Code Online (Sandbox Code Playgroud)
这个处理程序:
class MainHandler(webapp2.RequestHandler):
def get(self):
user = users.get_current_user()
if user == None:
self.redirect(users.create_login_url(self.request.uri))
geted_nickname = user.nickname()
Run Code Online (Sandbox Code Playgroud)
产生此错误:
File "C:\Users\Py\Desktop\Apps\contract\main.py", line 99, in get
geted_nickname = user.nickname()
AttributeError: 'NoneType' object has no attribute 'nickname'
Run Code Online (Sandbox Code Playgroud)
由于user是NoneType对象,程序应该执行if块self.redirect(users.create_login_url(self.request.uri)),但这不会发生.为什么?如何解决?
谢谢你的帮助!
这里是整个代码:
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file …Run Code Online (Sandbox Code Playgroud) 我正在尝试修改优秀的书编程集体智能提供的朴素贝叶斯分类器的代码,使其适应GAE数据存储区(提供的代码使用pysqlite2).但是试图这样做,我遇到了一个难以调试的错误.错误是这样的:
File "C:\Users\CG\Desktop\Google Drive\Sci&Tech\projects\naivebayes\main.py", line 216, in post
sampletrain(nb)
File "C:\Users\CG\Desktop\Google Drive\Sci&Tech\projects\naivebayes\main.py", line 201, in sampletrain
cl.train('Nobody owns the water.','good')
File "C:\Users\CG\Desktop\Google Drive\Sci&Tech\projects\naivebayes\main.py", line 139, in train
self.incf(f,cat)
File "C:\Users\CG\Desktop\Google Drive\Sci&Tech\projects\naivebayes\main.py", line 71, in incf
count=self.fcount(f,cat)
File "C:\Users\CG\Desktop\Google Drive\Sci&Tech\projects\naivebayes\main.py", line 92, in fcount
return float(res)
TypeError: float() argument must be a string or a number
Run Code Online (Sandbox Code Playgroud)
错误发生在这个块中:
def fcount(self,f,cat):
res = db.GqlQuery("SELECT * FROM fc WHERE feature =:feature AND category =:category", feature = f, category = cat).get()
# res=self.con.execute( …Run Code Online (Sandbox Code Playgroud) 我需要一个函数来转换年、月和日的十进制值。例如:1.5 年 = 1 年零 6 个月。2.2527397260273973 年 = 2 年 3 个月零 1 天。
我从这个功能开始:
function yearsToYearsMonthsDays(value){
var years = Math.floor(value);
var months = Math.floor( (value - years) /(1/12) );
var days = Math.floor ( ( (value - years) /(1/12) - Math.floor((value - years) /(1/12)) ) / (1/365) );
var result = years + " years, " + months + " months, " + days + " days";
Logger.log(result);
}
Run Code Online (Sandbox Code Playgroud)
但有时它不起作用(例如:0.75 不会产生 9 个月)。
有什么帮助吗?
python ×4
jinja2 ×2
syntax-error ×2
datastore ×1
debugging ×1
google-docs ×1
html ×1
javascript ×1
templates ×1