小编maz*_*zix的帖子

多个定义...链接器错误

我定义了一个特殊文件: config.h

我的项目还有文件:

t.c, t.h
pp.c, pp.h
b.c b.h
l.cpp
Run Code Online (Sandbox Code Playgroud)

和#includes:

在tc:

    #include "t.h"
    #include "b.h"
    #include "pp.h"
    #include "config.h"
Run Code Online (Sandbox Code Playgroud)

在bc:

    #include "b.h"
    #include "pp.h"
Run Code Online (Sandbox Code Playgroud)

在pp.c:

    #include "pp.h"
    #include "config.h"
Run Code Online (Sandbox Code Playgroud)

在l.cpp中:

    #include "pp.h"
    #include "t.h"
    #include "config.h"
Run Code Online (Sandbox Code Playgroud)

我的*.h文件中没有include指令,只在*.c文件中.我在config.h中定义了这个:

const char *names[i] =
        {
            "brian", "stefan", "steve"
        };
Run Code Online (Sandbox Code Playgroud)

并在l.cpp,tc,pp.c中需要该数组但是我收到此错误:

pp.o:(.data+0x0): multiple definition of `names'
l.o:(.data+0x0): first defined here
t.o:(.data+0x0): multiple definition of `names'
l.o:(.data+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [link] Error …
Run Code Online (Sandbox Code Playgroud)

c linker linker-errors

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

如何使用输入*.txt文件绘制一个非常简单的条形图(Python,Matplotlib)?

我使用Python 2.7和matplotlib.我有一个*.txt数据文件:

0 14-11-2003
1 15-03-1999
12 04-12-2012
33 09-05-2007
44 16-08-1998
55 25-07-2001
76 31-12-2011
87 25-06-1993
118 16-02-1995
119 10-02-1981
145 03-05-2014
Run Code Online (Sandbox Code Playgroud)

我的文件的第一列(数字)应该在我的条形图中的Y轴上,而我文件中的第二列(日期)应该在我的直方图中的轴OX上.我只知道如何阅读文件:

OX = []
OY = []

try :
    with open('data.txt', 'r') as openedFile :
        for line in openedFile :
            tab = line.split()
            OY.append(int(tab[0]))
            OX.append(str(tab[1]))
except IOError :
    print("IOError!")
Run Code Online (Sandbox Code Playgroud)

我确实读过matplotlib文档,但它仍然没有帮助我.我还想将我读到的日期添加到条形图中,使其看起来像

这个

有人可以帮帮我吗?

python matplotlib bar-chart

25
推荐指数
2
解决办法
15万
查看次数

如何在matplotlib python 2.6.6中我的图中的X轴上设置"步"?

我有一些代码:

#!/usr/bin/env python

import matplotlib
matplotlib.use("Agg")       
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1.2,1.9,3.1,4.2,4.8]

plt.plot(x,y)
plt.xlabel('OX')
plt.ylabel('OY')
plt.savefig('figure1.png')
plt.close()
Run Code Online (Sandbox Code Playgroud)

它给了我这个数字:我的身材

正如您所看到的,X轴上的"步长"为0.5,但我想将其设置为1.如何制作?

当我使用plt.xticks(1)它时给我错误:

回溯(最近一次调用最后一次):文件"overflow.py",第13行,在plt.xticks(1)文件"/usr/lib/pymodules/python2.6/matplotlib/pyplot.py",第998行,在xticks中locs = ax.set_xticks(args [0])文件"/usr/lib/pymodules/python2.6/matplotlib/axes.py",第2064行,在set_xticks中返回self.xaxis.set_ticks(ticks,minor = minor)文件"/usr/lib/pymodules/python2.6/matplotlib/axis.py",第1150行,在set_ticks中如果len(ticks)> 1:TypeError:类型为'int'的对象没有len()

我在Ubuntu 10.10上使用Python 2.6.6 ....

python matplotlib

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

为什么我应该在x86和x86_x64上使用'rdtsc'?

我知道rdtsc将处理器的时间戳计数器的当前值加载到两个寄存器中:EDX和EAX.为了在x86上获取它,我需要这样做(假设使用Linux):

    unsigned long lo, hi;
    asm( "rdtsc" : "=a" (lo), "=d" (hi));
    return lo;
Run Code Online (Sandbox Code Playgroud)

对于x86_x64:

        unsigned long lo, hi;
        asm( "rdtsc" : "=a" (lo), "=d" (hi) ); 
        return( lo | (hi << 32) );
Run Code Online (Sandbox Code Playgroud)

这是为什么?任何人都可以向我解释一下吗?

c cpu-registers rdtsc

16
推荐指数
2
解决办法
5430
查看次数

使用Beautiful Soup在python中解析网页

从网站上获取数据我遇到了一些麻烦.网站来源如下:

view-source:http://release24.pl/wpis/23714/%22La+mer+a+boire%22+%282011%29+FRENCH.DVDRip.XviD-AYMO
Run Code Online (Sandbox Code Playgroud)

有这样的事:

INFORMACJE O FILMIE

Tytuł............................................:Lameràboire

Ocena .............................................:IMDB - 6.3/10(24)

Produkcja .........................................:Francja

Gatunek ...........................................:Dramat

Czas trwania ......................................:98分钟

Premiera ..........................................:22.02.2012 - Świat

Reżyseria........................................:Jacques Maillot

Scenariusz ........................................:Pierre Chosson,Jacques Maillot

Aktorzy ...........................................:Daniel Auteuil,Maud Wyler ,YannTrégouët,Alain Beigel

我想从这个网站获得数据的Python列表:

[[Tytu?, "La mer à boire"]
[Ocena, "IMDB - 6.3/10 (24)"]
[Produkcja, Francja]
[Gatunek, Dramat]
[Czas trwania, 98 min.]
[Premiera, "22.02.2012 - ?wiat"]
[Re?yseria, "Jacques Maillot"]
[Scenariusz, "Pierre Chosson, Jacques Maillot"]
[Aktorzy, "Daniel Auteuil, Maud Wyler, Yann Trégouët, Alain Beigel"]]
Run Code Online (Sandbox Code Playgroud)

我使用BeautifulSoup编写了一些代码,但我不能再进一步了,我只是不知道从网站源代码中得到什么,以及如何转换为字符串...请帮忙!

我的代码:

    # -*- coding: utf-8 …
Run Code Online (Sandbox Code Playgroud)

python urllib beautifulsoup

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

如何解释openssl速度输出?

我跑openssl speed了我的Ubuntu电脑.一些结果:

Doing md4 for 3s on 16 size blocks: 9063888 md4's in 3.00s
Doing md4 for 3s on 64 size blocks: 7105157 md4's in 3.00s
Doing md4 for 3s on 256 size blocks: 4507884 md4's in 3.00s
Doing md4 for 3s on 1024 size blocks: 1809773 md4's in 2.99s
Doing md4 for 3s on 8192 size blocks: 275679 md4's in 3.00s
Run Code Online (Sandbox Code Playgroud)

这些数字究竟是什么意思?

  1. '做md4 for 3s'是什么意思?这是否意味着整个测试进行3次/秒?
  2. '2.99'中的'1809773 md4'是什么意思?
  3. '8192尺寸块'是什么意思?
The 'numbers' are in 1000s of bytes per second …
Run Code Online (Sandbox Code Playgroud)

openssl

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

if(!fork) - 这是什么意思?

这是什么意思if(!fork())?我有点困惑,我不知道我什么时候在父母和孩子的过程中:

if(!fork())
{
  // is it child or parent process?
}else{
  // is it child or parent process?
}
Run Code Online (Sandbox Code Playgroud)

c unix fork

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

空Netbeans 7调色板?如何恢复?

我在Kubuntu 12.04上使用Netbeans 7.我这样开始Netbeans:

netbeans --cp:a /usr/share/java/xercesImpl.jar & 
Run Code Online (Sandbox Code Playgroud)

Netbeans和Kubuntu 12.04已知问题的原因.在我的项目中间,我的调色板与Swing组件只是......消失了!

我只看到这样的事:

在此输入图像描述

如何恢复默认的Netbeans调色板?

我检查了Ctrl + Shift + 8快捷方式,但没有结果 - 问题仍然相同.

**编辑:我不知道我做了什么,但现在我只看到EMPTY调色板:(:**

在此输入图像描述

我也试过这个:

1)我发誓/home/mazix/.netbeans/7.0/config/Windows2Local/Groups/commonpalette ,只是看到了这个:CommonPalette.wstcgrp

2)cd'ed /home/mazix/.netbeans/7.0/config/Windows2Local/Components并看到这个:

AnalyzerTopComponent.settings output.settings AnalyzeStackTopComponent.settings projectTabLogical_tc.settings breakpointsView.settings projectTab_tc.settings CallHierarchyTopComponent.settings properties_1.settings callstackView.settings properties.settings CommonPalette.settings refactoring-preview.settings ComponentInspector.settings
ReporterResultTopComponent.settings CssPreviewTC.settings
resultsView.settings debugging.settings
search-results.settings DeclarationTopComponent.settings
services.settings evaluationator.settings
sessionsView.settings favorites.settings
sources.settings find-usages.settings
StyleBuilderTC.settings gsf-testrunner-results.settings
svnversioning.settings hgversioning.settings
synchronize.settings JavadocTopComponent.settings
TaskListTopComponent.settings localsView.settings
TerminalContainerTopComponent.settings MultiView-java#007Cform#007C_1.settings threadsView.settings MultiView-java#007Cform#007C_2.settings versioning_output.settings MultiView-java#007Cform #007C_4.settings watchesView.settings MultiView-java#007Cform#007C.settings Welcome.settings navigatorTC.settings

并没有看到任何_hidden文件:(

java user-interface netbeans palette netbeans-7

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

如何计算fasta格式文件中的氨基酸?

我找到了解析fasta frmated文件的代码.我需要计算每个序列中有多少A,T,G等,例如:

>gi|7290019|gb|AAF45486.1| (AE003417) EG:BACR37P7.1 gene product [Drosophila melanogaster]
MRMRGRRLLPIIL 
Run Code Online (Sandbox Code Playgroud)

在这个序列中:

M - 2
R - 4
G - 1
L - 3
I - 2
P - 1
Run Code Online (Sandbox Code Playgroud)

代码很简单:

 def FASTA(filename):
  try:
    f = file(filename)
  except IOError:                     
    print "The file, %s, does not exist" % filename
    return

  order = []
  sequences = {}

  for line in f:
    if line.startswith('>'):
      name = line[1:].rstrip('\n')
      name = name.replace('_', ' ')
      order.append(name)
      sequences[name] = ''
    else:
      sequences[name] += line.rstrip('\n').rstrip('*')

  print "%d sequences found" …
Run Code Online (Sandbox Code Playgroud)

python bioinformatics fasta biopython

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

基准测试 - CPU时间大于待机时间?

我在linux上测量排序算法的cpu时间和挂起时间.我getrusage用来测量cpu时间并clock_gettime CLOCK_MONOTONIC获得一个待机时间.虽然我注意到cpu时间比壁时间大 - 这是正确的吗?我一直认为cpu时间必须小于壁时间.我的例子结果:

3.000187 seconds  [CPU]
3.000001 seconds  [WALL]
Run Code Online (Sandbox Code Playgroud)

c benchmarking microbenchmark

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