小编Kar*_*itz的帖子

如何使用python tarfile模块将文件附加到tar文件?

我想在tar文件中附加一个文件.例如,文件test.tar.gza.png, b.png, c.png.我有一个新的名为png文件a.png,我想追加到a.pngtest.tar.gz并覆盖旧的文件a.pngtest.tar.gz.我的代码:

import tarfile
a = tarfile.open('test.tar.gz', 'w:gz')
a.add('a.png')
a.close()
Run Code Online (Sandbox Code Playgroud)

然后,所有文件都test.tar.gz消失但是a.png,如果我将我的代码更改为:

import tarfile
a = tarfile.open('test.tar.gz', 'a:')# or a:gz
a.add('a.png')
a.close()
Run Code Online (Sandbox Code Playgroud)

程序崩溃,错误日志:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/tarfile.py", line 1678, in open
    return func(name, filemode, fileobj, **kwargs)
  File "/usr/lib/python2.7/tarfile.py", line 1705, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "/usr/lib/python2.7/tarfile.py", line 1588, in __init__ …
Run Code Online (Sandbox Code Playgroud)

python tarfile

13
推荐指数
2
解决办法
3898
查看次数

python thrift错误```TSocket读取0字节```

我的python版本:2.7.8
thrift版本:0.9.2
python-thrift版本:0.9.2
操作系统:
centOS 6.8 我的test.thrift文件:

const string HELLO_IN_KOREAN = "an-nyoung-ha-se-yo"
const string HELLO_IN_FRENCH = "bonjour!"
const string HELLO_IN_JAPANESE = "konichiwa!"

service HelloWorld {
  void ping(),
  string sayHello(),
  string sayMsg(1:string msg)
}
Run Code Online (Sandbox Code Playgroud)

client.py

# -*-coding:utf-8-*-

from test import HelloWorld
from test.constants import *

from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol


# Make socket
transport = TSocket.TSocket('192.168.189.156', 30303)

# Buffering is critical. Raw sockets are very slow
transport = TTransport.TBufferedTransport(transport)

# …
Run Code Online (Sandbox Code Playgroud)

python thrift

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

如何使用spring boot和jpa上传文件并将文件保存在db中?

我是spring boot的新手,我想使用spring boot上传一个小文件并将其保存在db use jpa中。但是我没有很好的分辨率。我的程序如下:
数据库表:

CREATE TABLE `report` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `logo` BLOB NOT NULL,
  `created_time` int(10) NOT NULL,
  `updated_time` int(10) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8
Run Code Online (Sandbox Code Playgroud)

jpa bean:
Report.java

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import java.io.Serializable;

@Entity
@Table(name="mf_report")
public class Report implements Serializable{
    @Column(name="id")
    private int id;

    @Column(name="name")
    private String name;

    @Lob
    @Column(name="logo", length=100000)
    private byte[] logo;

    public int getId() {
        return id;
    }

    public void setId(int …
Run Code Online (Sandbox Code Playgroud)

java spring jpa

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

如何在 pycharm 中配置 golang 插件?

我想开发 Go 使用 pycharm。我的golang版本是1.4.2。我的pycharm版本是4.5.2。我的操作系统是Mac OSX 10.10.3。我在我的Mac上配置了GOROOT和GOPATH。如图: 在此处输入图片说明

我从这个url下载了 golang 插件。但是当我安装插件并重新启动 pycharm 时,IDE 显示没有 gopath 和 goroot。消息:

在此处输入图片说明

怎么了?

macos go pycharm

5
推荐指数
1
解决办法
2098
查看次数

标签 统计

python ×2

go ×1

java ×1

jpa ×1

macos ×1

pycharm ×1

spring ×1

tarfile ×1

thrift ×1