我正在使用python ftplib将图像上传到位于/ var/www的raspberryPi上的文件夹.一切都工作正常,除了上传的文件有600权限,我需要644它们.
这是最好的方法吗?我正在寻找类似的东西:
def ftp_store_avatar(name, image):
ftp = ftp_connect()
ftp.cwd("/img")
file = open(image, 'rb')
ftp.storbinary('STOR ' + name + ".jpg", file) # send the file
[command to set permissions to file]
file.close()
ftp.close()
Run Code Online (Sandbox Code Playgroud) 我正在使用R&the igraphpackage来绘制用graphml编写的图形,我想使用weight此语法中包含的参数
<edge id="e389" source="w4" target="w0">
<data key="d1">0.166666666667</data>
</edge>
Run Code Online (Sandbox Code Playgroud)
我可以用它获得价值
weight = E(f)$weight // f is the graph
Run Code Online (Sandbox Code Playgroud)
但weight在计算之前我不知道如何使用df = degree(f)
有关详细信息:所有节点都相互连接,权重为1 /(number_of_nodes - 1),因此每个节点的度数应为1.
graphml文件
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="d0" for="node" attr.name="label" attr.type="string"/>
<key id="d1" for="edge" attr.name="weight" attr.type="float"/>
<key id="d2" for="node" attr.name="type" attr.type="string"/>
<key id="d3" for="node" attr.name="tweet" attr.type="int"/>
<key id="d4" for="node" attr.name="color" attr.type="string"/>
<graph id="G" edgedefault="undirected">
<node id="w4">
<data key="d0">value1</data>
<data key="d2">word</data>
<data key="d1">0.166666666667</data>
<data key="d4">green</data>
</node>
.
.
.
<node …Run Code Online (Sandbox Code Playgroud) 我有一个程序在服务器上的.txt文件中输出一个列表,我想将该列表保存在一个新变量中.
我正在做:
with open ("file.txt", "r") as myfile:
data = myfile.read().replace('\n', '')
var = data
Run Code Online (Sandbox Code Playgroud)
但显然会print(var)返回一个字符串"[list, of, stuff]"
是的,我可以绕过txt-save程序,但万一我不能?