小编use*_*960的帖子

如何在Ubuntu上安装SQLAlchemy?

我想在Ubuntu上安装Python和SQLAlchemy.这是我的命令:

sudo easy_install sqlalchemy
Run Code Online (Sandbox Code Playgroud)

但它失败了,我该怎么办?

python linux sqlalchemy

10
推荐指数
2
解决办法
3万
查看次数

如何在ubuntu上安装scrapy?

我知道scrapy应首先安装w3lib,所以我先安装w3lib,但是当我在python ide中导入scrapy时,程序崩溃了.错误:

creating Twisted.egg-info

writing requirements to Twisted.egg-info\requires.txt

writing Twisted.egg-info\PKG-INFO

writing top-level names to Twisted.egg-info\top_level.txt

writing dependency_links to Twisted.egg-info\dependency_links.txt

writing manifest file 'Twisted.egg-info\SOURCES.txt'

warning: manifest_maker: standard file '-c' not found



reading manifest file 'Twisted.egg-info\SOURCES.txt'

writing manifest file 'Twisted.egg-info\SOURCES.txt'

copying twisted\internet\_sigchld.c -> build\lib.win-amd64-2.7\twisted\internet

creating build\lib.win-amd64-2.7\twisted\internet\iocpreactor\iocpsupport

copying twisted\internet/iocpreactor/iocpsupport\iocpsupport.c -> build\lib.win-amd64-2.7\twisted\internet/iocpreactor/i
ocpsupport

copying twisted\internet/iocpreactor/iocpsupport\winsock_pointers.c -> build\lib.win-amd64-2.7\twisted\internet/iocpreac
tor/iocpsupport

copying twisted\python\_epoll.c -> build\lib.win-amd64-2.7\twisted\python

copying twisted\python\_initgroups.c -> build\lib.win-amd64-2.7\twisted\python

copying twisted\python\sendmsg.c -> build\lib.win-amd64-2.7\twisted\python

copying twisted\runner\portmap.c -> build\lib.win-amd64-2.7\twisted\runner

copying twisted\test\raiser.c -> build\lib.win-amd64-2.7\twisted\test

running build_ext
Run Code Online (Sandbox Code Playgroud)

怎么了?

python-2.7

7
推荐指数
2
解决办法
9456
查看次数

“python”中的错误:损坏的大小与 prev_size

我用c写了一个python扩展。
我使用c程序来加密一个字符串。
我的c程序:

#include <Python.h>

static const char *codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

static const unsigned char map[256] = {
        255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 255,
        255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
        255, 255, 255, 255, 255, 255, 255, 255, 253, 255, 255, 255,
        255, 255, 255, 255, 255, 255, 255,  62, 255, 255, 255,  63,
        52,  53,  54,  55,  56,  57,  58,  59,  60,  61, 255, 255,
        255, 254, …
Run Code Online (Sandbox Code Playgroud)

c python

4
推荐指数
1
解决办法
2万
查看次数

替换在 Python 3 中不起作用的字节

Python版本:3.5.2
我的代码:

a = b"\xff"
b = a.replace(b"f", b"d")
print(b)
Run Code Online (Sandbox Code Playgroud)

我有b'\xff'。我尝试了另一种方法。首先,我将字节转换为str,然后替换字符串。

a = b"\xff"
b = a.decode()
b = b.replace("f", "d")
Run Code Online (Sandbox Code Playgroud)

但通过例外:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决 python3 中的问题。我应该怎么办?

python python-3.x

4
推荐指数
2
解决办法
1万
查看次数

如何在Python 3中将字节转换为字符串

我想编写一个返回字符串而不是字节的函数。
功能:

def read_image(path):
    with open(path, "rb") as f:
        data = f.read()
    return data
image_data = read_image("/home/user/icon.jpg")
Run Code Online (Sandbox Code Playgroud)

如何将值转换image_data为类型str。如果成功转换为字符串,如何将字符串转换为字节。

python python-3.x

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

python ×4

python-3.x ×2

c ×1

linux ×1

python-2.7 ×1

sqlalchemy ×1