我使用pylint来检查我的python代码,并发现了这个约定问题:
C:11, 0: Wrong continued indentation before block.
+ this_time <= self.max):
^ | (bad-continuation)
Run Code Online (Sandbox Code Playgroud)
我试图改进时间,但问题仍然存在,有人可以帮忙吗?谢谢!
if len(remaining_obj_list) > 0:
for i in a_list:
this_time = self.__get_time(i)
for remaining_obj in remaining_obj_list:
if (remaining_obj.get_time() # to fit 78 char rule
+ this_time <= self.max):
i.append(remaining_obj)
remaining_obj.set_used(True)
if 0 == len(self.__get_unused_list):
break
Run Code Online (Sandbox Code Playgroud) 我打算编写一个Python程序来检查文件是否在我的Google云端存储的某个文件夹中,基本的想法是获取list文件夹中的所有对象,文件名list,然后检查文件abc.txt是否在文件名list.
现在的问题是,看起来Google只提供了一种获取方式obj list,即uri.get_bucket()下面的代码来自https://developers.google.com/storage/docs/gspythonlibrary#listing-objects
uri = boto.storage_uri(DOGS_BUCKET, GOOGLE_STORAGE)
for obj in uri.get_bucket():
print '%s://%s/%s' % (uri.scheme, uri.bucket_name, obj.name)
print ' "%s"' % obj.get_contents_as_string()
Run Code Online (Sandbox Code Playgroud)
缺点uri.get_bucket()是,看起来它首先得到所有的对象,这是我不想要的,我只需要得到特定文件夹的obj名称list(例如gs//mybucket/abc/myfolder),这应该很快.
有人可以帮忙回答吗?感谢每一个答案!
python google-cloud-storage gcloud-python google-cloud-python
我编写了一个Python脚本来检查GCS中的文件,它使用wxpython生成GUI。为了进行身份验证,我是以这种方式进行的(遵循Google示例代码中的方法-> http://code.google.com/p/google-cloud-platform-samples/source/browse/file-transfer-json/chunked_transfer。 py?repo = storage):
flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE,
# the secrets file I put in same folder
scope=scope,
message=MISSING_CLIENT_SECRETS_MESSAGE)
credential_storage = CredentialStorage(CREDENTIALS_FILE) # the file to store
# authentication credentials
credentials = credential_storage.get()
if credentials is None or credentials.invalid:
credentials = run_oauth2(flow, credential_storage)
self.printLog('Constructing Google Cloud Storage service...')
http = credentials.authorize(httplib2.Http())
return discovery_build('storage', 'v1beta1', http=http)
Run Code Online (Sandbox Code Playgroud)
上面的代码包含在我的Python脚本中,当它只是一个python .py文件时效果很好,后来我用pyinstaller在win 7 64bit中将其转换为.exe(我也将秘密文件与.exe文件),使用以下命令
C:\ gcs_file_check> python pyinstaller-2.0 \ pyinstaller.py -w gcs_file_check.py
单击exe时,正确启动了Google 的“ 请求权限”页面(因为它运行的是Python脚本而不是exe),但是单击“接受”后,上面的代码将引发异常:
[Errno 185090050] _ssl.c:343:错误:0B084002:x509证书例程:X509_load_cert_crl_file:系统库
而且我可以看到文件certificate.json不是由.exe创建的,而Python脚本可以正确创建此文件。
有人知道这是怎么发生的以及如何解决吗?感谢每个答案!
=================== …
python pyinstaller google-cloud-storage google-api-python-client
django.db.utils.OperationalError: (1045:Access denied for user 'root'@'localhost' (using password: NO)在mac中安装Mysql 8.0并更改默认root密码后,当我运行连接MySql和初始化数据库表时出现错误python3 manage.py migrate,而我可以在控制台中使用root/新密码登录mysql而没有任何错误。
而且是使用pymysql来配合Mysql,我查了很多google,也在stackorverflow中找到了解决方案,最后在CSDN的技术博客中找到了解决方案
只是想在stackoverflow上分享一下,如果你也遇到了这个问题,你可能想尝试下面答案中的方法。
请参阅我的正则表达式模式代码:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re
print 'Start'
str1 = 'abcdefgasdsdfswossdfasdaef'
m = re.match(r"([A-Za-z\-\s\:\.]+)+(\d+)\w+", str1) # Want to match something like 'Moto 360x'
print m # None is expected.
print 'Done'
Run Code Online (Sandbox Code Playgroud)
完成需要49秒,模式有什么问题吗?