可能重复:
Postgresql无法启动
这个问题一直让我发疯,似乎没有什么工作.我需要更改postgresql存储数据库的位置.当我在终端中使用命令时,我是一个完整的新手,并且使用正确的命令逐步执行指令确实会有所帮助.我搜索了整个网络,但所有说明都假设对终端命令有一些先验的知识.我确实尝试了一种方法,在主数据文件夹中创建一个符号链接到我所需的位置.这给了我一个错误,要求我检查日志文件.但是,我不知道日志文件在哪里.很多人似乎都有这个问题,一步一步的解决方案肯定会有所帮助.我的Psql版本是8.4.Ubuntu 10.10
将某个字符串插入数据库时,我遇到了非常令人沮丧的错误.它说:
Python无法解码字节字符,期待unicode"
经过大量的搜索,我看到我可以通过将我的字符串编码为Unicode来克服这个错误.我尝试首先解码字符串,然后以UTF-8格式对其进行编码.喜欢:
string = string.encode("utf8")
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
'ascii' codec can't decode byte 0xe3 in position 6: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)
我一直在为这个错误而死!我如何解决它?
我有两个包含日期的字符串"
start_date = 'Sun Sep 16 16:05:15 +0000 2012'
end_date = 'Sun Sep 17 23:55:20 +0000 2012'
Run Code Online (Sandbox Code Playgroud)
我需要执行:end_date - start_date
它应该返回分隔结束日期和开始日期的秒数.
此数据从twitter api中提取.这就是json给我的.由于它看起来像一个常用的字符串,我假设有一个库或方法可以处理这个.我只是找不到一个.谢谢!
我有一个数据库集合(命名为fols),如下所示:
{'followers':
{
'123':1
'123':2
'123':3
}
}
Run Code Online (Sandbox Code Playgroud)
如果我运行查询(使用pymongo):
cursor = fols.find()
cursor.count()
>>3
Run Code Online (Sandbox Code Playgroud)
工作良好.现在:
cursor = fols.find({'followers':{'123':1}})
cursor.count()
>>1
Run Code Online (Sandbox Code Playgroud)
再次正常工作.但如果我尝试:
cursor = fols.find({'followers':{'123':{'$exists': True}}})
cursor.count()
>> 0
Run Code Online (Sandbox Code Playgroud)
即使有3条记录,它也会返回0.
如果有推文,我需要获得转发我的推文的前100位用户.即:如果我的推文有600条重新推文,我需要前100个用户的用户ID.不是最新的100.有一个API调用找到最新的100人,但有没有办法扭转这一局并获得前100名?或者有没有办法绕过100个用户限制并选择所有用户?
我正在尝试安装matplotlib但面临许多问题.我收到来自pip install matplotlib的常见错误以及尝试从source构建,它是:
BUILDING MATPLOTLIB
matplotlib: 1.1.1
python: 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1
Compatible Apple Clang 4.0
(tags/Apple/clang-418.0.60)]
platform: darwin
Run Code Online (Sandbox Code Playgroud)
需要的依赖
numpy: 1.6.1
* Could not find the headers for numpy. You may
* need to install the development package.
Run Code Online (Sandbox Code Playgroud)
编辑:终于解决了.我需要安装gfortran和gcc编译器.它是否使用brew,一切都像魅力一样!
我有一个程序,它需要一个非常庞大的输入文件,并从中产生一个字典.由于这不适合内存,我决定使用shelve将其写入我的磁盘.现在我需要利用我的系统中的多个核心(其中8个),这样我就可以加快解析速度.我认为最明显的方法是将输入文件分成8个部分,同时在所有8个部分上运行代码.问题是我最后只需要一本字典.不是8个.那么如何使用shelve并行更新单个字典呢?
我几天前在我的ubuntu机器上安装了mongodb,我正在使用它没有任何问题.今天我不得不重启我的电脑.在那之后,mongo根本不会开始.它说:
Wed Sep 12 21:41:21 [initandlisten] exception in initAndListen: 10296 dbpath (/data/db/) does not exist, terminating
Run Code Online (Sandbox Code Playgroud)
几个小时前它工作正常,现在它已经搞砸了重启.我有很多重要的数据存储在那里,我真的希望它不会全部丢失!我需要找到该数据并再次对该数据运行mongodb.我使用pymongo来与mongodb进行交互.
我刚看到配置文件,它将数据存储在/ var/lib/mongod中作为dpath.现在我如何启动mongodb指定这个dpath?
我有一个列表/数组字符串:
l = ['jack','jill','bob']
Run Code Online (Sandbox Code Playgroud)
现在我需要在slite3中为python创建一个表,使用它可以将此数组插入名为"Names"的列中.我不希望每行中有多个每个名称的行.我想要一个包含完全如上所示的数组的行,我希望能够以完全相同的格式检索它.如何在数据库中插入数组作为元素?在创建db本身时,我应该将其声明为数组的数据类型?喜欢:
c.execute("CREATE TABLE names(id text, names ??)")
Run Code Online (Sandbox Code Playgroud)
我如何插入值?喜欢:
c.execute("INSERT INTO names VALUES(?,?)",(id,l))
Run Code Online (Sandbox Code Playgroud)
编辑:我是如此愚蠢.我刚刚意识到我可以为id创建多个条目,并使用查询来提取所有相关名称.不管怎么说,还是要谢谢你!
我正在尝试使用 spinn3r 的数据。数据作为 protobuf 返回。在 python 中,当我打印 protobuf 对象时,我得到这个:
print data
source {
link {
href: ""
resource: ""
}
canonical_link {
href: "http://twitter.com/_PattiShaw/statuses/28167079857225728"
resource: ""
}
title: ""
hashcode: ""
lang {
code: "en"
probability: -1.0
}
generator: ""
description: ""
last_posted: ""
last_published: ""
date_found: ""
publisher_type: "MICROBLOG"
}
feed {
link {
href: ""
resource: ""
}
canonical_link {
href: ""
resource: ""
}
title: ""
hashcode: ""
lang {
code: "en"
probability: -1.0
}
generator: "" …
Run Code Online (Sandbox Code Playgroud) python ×6
mongodb ×2
sqlite ×2
string ×2
list ×1
macos ×1
matplotlib ×1
postgresql ×1
pymongo ×1
shelve ×1
sql ×1
subtraction ×1
terminal ×1
twitter ×1
ubuntu ×1