1

subprocess.check_output(('/Applications/googlecl-0.9.13/build/scripts-2.7/google', 'docs', 'get', r'"重新评估请求"', r'--format', 'csv' , r'/Users/myaccount/Desktop'), shell=True)

此代码不会拉下文档,但运行相同的行将在终端内工作。它可能没有时间完成?从命令行运行它需要一段时间。

有一个 Python 错误:“Traceback(最近一次调用最后一次):文件“/Users/myaccount/Desktop/reassess2.py”,第 17 行,在 subprocess.call('google docs get "Reassessment Request" --format csv /Users /myaccount/Desktop') 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”,第 493 行,调用返回 Popen(*popenargs, **kwargs).wait( )文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”,第679行,在init errread,errwrite)文件“/Library/Frameworks/Python.framework/Versions/2.7 /lib/python2.7/subprocess.py",第 1249 行,在 _execute_child raise child_exception OSError: [Errno 2] No such file or directory"

当我尝试在 OSX 脚本中运行它时遇到类似的问题:当我运行 shell 脚本(运行上面的命令行)时,我得到: ?/Users/myaccount/Desktop/ReScript.sh ;出口; .csvloading Reassessment Request to /users/myaccount/Desktop logout

[处理完成]”,但实际上没有下载文件。

OSX 山狮;0.9.13 厘升;2.0.17 gdata(我认为 - 不是最新的,但与 cl 一起使用的那个)

谢谢您的帮助!

4

1 回答 1

0

Google CL 几乎即将退出市场,Google Drive 的新表单更新已经打破了这些类型的操作。我使用 Gdata 作为解决方法有一段时间,但如果有人试图使用其中任何一个并偶然发现这一点,这是当前最好的答案:Gspread。它安装方便(不像其他版本兼容性问题那样),需要更少的代码,而且速度更快。

使用 Gspread,此代码将替换为:

username = 'jimjam@gmail.com'
password = 'bwdfsdfsafadlhsw'
sheetname = "Reassessment Requesttemp"

client = gspread.login(username, password)
spreadsheet = client.open(sheetname)

worksheet = spreadsheet.sheet1
contents = worksheet.get_all_values()
于 2014-09-14T23:56:50.177 回答