我想在tar文件中附加一个文件.例如,文件test.tar.gz
是a.png, b.png, c.png
.我有一个新的名为png文件a.png
,我想追加到a.png
到test.tar.gz
并覆盖旧的文件a.png
在test.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版本: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) 我是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) 我想开发 Go 使用 pycharm。我的golang版本是1.4.2。我的pycharm版本是4.5.2。我的操作系统是Mac OSX 10.10.3。我在我的Mac上配置了GOROOT和GOPATH。如图:
我从这个url下载了 golang 插件。但是当我安装插件并重新启动 pycharm 时,IDE 显示没有 gopath 和 goroot。消息:
怎么了?