小编Guy*_*ton的帖子

如何将boost :: optional设置回未初始化状态?

我如何"重置"/"取消设置" boost::optional

optional<int> x;

if( x )
{
  // We won't hit this since x is uninitialized
}
x = 3;
if( x )
{
  // Now we will hit this since x has been initialized
}
// What should I do here to bring x back to uninitialized state?
if( x )
{
  // I don't want to hit this
}
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-optional

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

使用python进行Web Scraping数据?

我刚开始使用Python学习网页抓取.但是,我已经遇到了一些问题.

我的目标是从fishbase.org网上废弃不同金枪鱼品种的名称(http://www.fishbase.org/ComNames/CommonNameSearchList.php?CommonName=salmon)

问题:我无法提取所有物种名称.

这是我到目前为止:

import urllib2
from bs4 import BeautifulSoup

fish_url = 'http://www.fishbase.org/ComNames/CommonNameSearchList.php?CommonName=Tuna'
page = urllib2.urlopen(fish_url)

soup = BeautifulSoup(html_doc)

spans = soup.find_all(
Run Code Online (Sandbox Code Playgroud)

从这里开始,我不知道如何提取物种名称.我曾想过使用正则表达式(即soup.find_all("a", text=re.compile("\d+\s+\d+"))捕获标签内的文本......

任何输入将受到高度赞赏!

html python beautifulsoup web-scraping

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

用通用样式在C中实现堆栈

file stack.h

typedef struct
{
    void *elems;
    int elem_size;
    int log_len;
    int alloc_len;
    void (*free_fn)(void *);
} stack;

void stack_new(stack *s, int elem_size, void (*free_fn)(void *));
void stack_dispose(stack *s);
void stack_push(stack *s, void *value);
void stack_pop(stack *s, void *address);
Run Code Online (Sandbox Code Playgroud)

和实现文件stack.c

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define assert(condition) if(!condition) printf("assert fail\n");exit(0) 

void strfree(void *elem);

int main()
{
    stack s;
    int i;
    char *copy, *top;
    const char *friends[] = {"joe", "castiel", "lily"};
    stack_new(&s, sizeof(char *), strfree);
    for(i=0; i<3; i++)
    {
        copy …
Run Code Online (Sandbox Code Playgroud)

c generics

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

标签 统计

beautifulsoup ×1

boost ×1

boost-optional ×1

c ×1

c++ ×1

generics ×1

html ×1

python ×1

web-scraping ×1