嗯,这一定是个傻瓜.下面是C中不可能更简单的代码.它不能编译说"未定义的睡眠引用".但我想我包括我需要的所有系统头...
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("Test starts.\n");
sleep(1);
printf("Test ends.\n");
return 1;
}
Run Code Online (Sandbox Code Playgroud) 我刚刚度假一个月,所以无法说明发生这种情况的确切点,但是R从官方的Arch repos现在无法启动,引用
/usr/lib64/R/bin/exec/R: error while loading shared libraries:
libgfortran.so.3: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我认为也许一个符号链接被错误地放置或销毁,所以我查看了/ usr/lib来尝试找到它:
ls -halt /usr/lib/libgfortran.so.*
lrwxrwxrwx 1 root root 20 May 16 03:01 /usr/lib/libgfortran.so.4 -> libgfortran.so.4.0.0
-rwxr-xr-x 1 root root 7.1M May 16 03:01 /usr/lib/libgfortran.so.4.0.0
Run Code Online (Sandbox Code Playgroud)
已libfortran.so.3被libgfortran.so.4Arch 取代?如果是这样,是否有任何可能的解决方法R来运行旧版本?
pacman -Qi r
Name : r
Version : 3.4.0-2
Description : Language and environment for statistical computing and graphics
Architecture : x86_64
URL : http://www.r-project.org/
Licenses …Run Code Online (Sandbox Code Playgroud) 我有以下列表:
['|', u'MOM', u'DAD', '|', u'GRAND', '|', u'MOM', u'MAX', u'JULES', '|']
Run Code Online (Sandbox Code Playgroud)
并希望它被"|"拆分 所以结果看起来像:
[[u'MOM', u'DAD'],[ u'GRAND'], [u'MOM', u'MAX', u'JULES']]
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?我只在网上找到需要一定长度元素的子列表示例
有人问这里时,把原因1和True在set仅1被保留.
这当然是因为1==True.但在哪些情况下1保留并保留哪些情况True?
让我们来看看:
传递一个list来构建set而不是使用set符号:
>>> set([True,1])
{True}
>>> set([1,True])
{1}
Run Code Online (Sandbox Code Playgroud)
似乎是逻辑的:set迭代内部列表,并且不添加第二个元素,因为它等于第一个元素(注意set([True,1]) 不能产生1,因为set无法知道列表中的内容.它甚至可能不是list一个可迭代的)
现在使用set符号:
>>> {True,1}
{1}
>>> {1,True}
{True}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,似乎是以相反的顺序处理项目列表(在Python 2.7和Python 3.4上测试).
但这有保证吗?或者只是一个实现细节?
我不确定如何将li元素放在浅绿色空间中,仅基于我围绕它们创建的绿色正方形。截至目前,CSS包括居中时项目符号要占用的空间,我不希望这样做。
#square {
position: fixed;
width: 350px;
height: 100%;
top: 0px;
left: 0px;
background-color: rgb(230, 255, 230);
}
ul {
position: relative;
bottom: 30px;
display: flex;
flex-direction: column;
align-items: center;
}
li {
margin-top: 40px;
padding-left: 75px;
border-color: white;
border-width: 2px;
border-style: solid;
padding: 5px 20px 5px 20px;
background-color: green;
border-radius: 10px;
width: 100px;
text-align: center;
}
.navlink {
text-decoration: none;
color: white;
}Run Code Online (Sandbox Code Playgroud)
<div id="square">
<ul>
<li><a class="navlink" href="#">Introduction</a></li>
<li><a class="navlink" href="#">Middle</a></li>
<li><a class="navlink" href="#">End</a></li>
</ul>
</div> …Run Code Online (Sandbox Code Playgroud)我有一个目标,build.xml它创建一个Zip文件.为了避免在没有更新文件的情况下创建Zip,我想事先检查更新.AFAIK,uptodate是使用的任务.
以下是相关(简化)脚本部分:
<filelist id="zip-files">
<file name="C:/main.exe" />
<file name="D:/other.dll" />
</filelist>
<target name="zip" depends="zip-check" unless="zip-uptodate">
<zip destfile="${zip-file}" >
<filelist refid="zip-files" />
</zip>
</target>
<target name="zip-check">
<uptodate property="zip-uptodate"
targetfile="${zip-file}">
<srcfiles refid="zip-files" />
</uptodate>
</target>
Run Code Online (Sandbox Code Playgroud)
但是,uptodate失败因为srcfiles必须引用a fileset,而不是a filelist.仍然,我不能使用a,fileset因为它需要一个dir属性,我无法设置,因为源文件不共享基目录.
当然,我可以在压缩它们之前将所有文件复制到公共目录,从而能够使用fileset,但我想知道是否有替代解决方案.
我正在使用Ant 1.8.1
我对Python中的字典有疑问.
这里是:
我有一个像这样的字典 dict = { 'abc':'a', 'cdf':'b', 'gh':'a', 'fh':'g', 'hfz':'g' }
现在我希望以相同的值获取所有Key-Elements并将其保存在新的dict中.
新的Dict应该是这样的:
new_dict = { 'b':('cdf'), 'a':('abc','gh'), 'g':('fh','hfz')}
几个月后我开始使用Visual Studio 2015,只是注意到Icon Editor缺失了!在Visual Studio的早期版本中,我总是使用图像编辑器来编辑图标,但是在2015年我找不到它,如果我双击图标文件就会打开Paint.
也许我忘了安装上的东西或微软是否从Visual Studio中删除它?
谢谢
弗朗切斯科
我有一个子进程,要么退出返回码,要么问一些东西,等待用户输入.
我想检测过程何时提出问题并立即退出.过程提出问题的事实足以让我决定系统的状态.
问题是我无法阅读这个问题,因为子进程可能不会刷新标准输出.所以我不能依赖解析subprocess.Popen().stdout:当试图读取它时,它会阻塞因为首先读取输入.
有点像这样
# ask.py, just asks something without printing anything if a condition is met
# here, we'll say that the condition is always met
input()
Run Code Online (Sandbox Code Playgroud)
当然,实际的子进程是第三方二进制文件,我无法轻松修改它以添加必要的刷新调用,这将解决它.
我还可以尝试相当于Windows unbuffer(相当于Windows上的unbuffer程序?)的Windowswinpty,这可能(可能)允许我检测输出并解决我当前的问题,但我想保持简单和我想首先解决标准输入问题...
我想......嗯,很多事情不工作,包括试图通过假文件作为stdin参数,它不起作用,因为subprocess需要的fileno文件,我们不能给它的垃圾...
p = subprocess.Popen(["python","ask.py"],...)
Run Code Online (Sandbox Code Playgroud)
使用communicate字符串也不起作用,因为您无法控制何时读取字符串以供应给子进程(可能通过系统管道).
这些问题很有希望,但要么依赖标准输出,要么仅适用于Linux
我目前正在做的是超时运行进程,如果超时,我决定程序被阻止.但它花费了超时等待时间.如果我能stdin在子进程读取后尽快做出决定,那就更好了.
我想知道是否有一个本机python解决方案(可能使用ctypes和Windows扩展)来检测从stdin读取.但是,本机解决方案不使用Python而是使用非Microsoft专有语言.
我有test.h一个包含类的.h文件.在这个类中有一个私有方法返回一个我不想做"公共"的类型的指针,但我希望能够将此test.h文件包含在其他源文件中.
通常,在.h文件中使用前向声明很容易:
class Foo;
Run Code Online (Sandbox Code Playgroud)
但问题是这种类型来自一个我无法改变的C文件(因为它是我不维护的其他代码)而且它是一个typedef.
基本上我的意思test.cpp是:
// this type comes from a C file, cannot be changed to struct or class
typedef struct
{
int x;
} Foo;
#include "test.h"
static Foo foo;
Foo *Test::private_function()
{
foo.x = 12;
return &foo;
}
int Test::compute()
{
auto *local_foo = private_function();
return local_foo->x;
}
Run Code Online (Sandbox Code Playgroud)
我的test.h文件是:
#pragma once
struct Foo;
class Test
{
public:
Test() {}
int compute();
private:
Foo *private_function(); …Run Code Online (Sandbox Code Playgroud)