小编Kip*_*per的帖子

React & Reselect 选择器声称更新后状态相同

我正在我的项目中实施 Reselect 并且对如何正确使用它有点困惑。在遵循有关如何使用重新选择的多个教程和文章之后,我使用了相同的模式,但仍然无法按预期工作。

我的选择器:

const getBaseInfo = (state) => state.Info;
const getResources = (state) => state.Resources;

export const ASelector = createSelector(
  [getBaseInfo, getResources],
  (items, resources) => { 
    let result = {};
    for(const item in items) {
      console.log(item);
      result[item] = _.pick(items[item], ['Title', 'Type', 'Beginning', 'minAmount', 'Address'])
    }
    for(const item in resources) {
      console.log(item);
      result[item] = {...result[item], firstImage: resources[item].firstImage}
    }
    return result;
  }
);
Run Code Online (Sandbox Code Playgroud)

mapStateToProps 组件:

function mapStateToProps(state) {
  console.log(state);
  return { 
    gridInfo: ASelector(state)
  }
}
Run Code Online (Sandbox Code Playgroud)

现在起初我的初始状态是:

state = { Info: {}, …
Run Code Online (Sandbox Code Playgroud)

reactjs redux react-redux reselect

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

docx 在 python 中列出

我正在尝试读取 docx 文件并将文本添加到列表中。现在我需要列表包含来自 docx 文件的行。

例子:

.docx 文件:

"Hello, my name is blabla,
I am 30 years old.
I have two kids."
Run Code Online (Sandbox Code Playgroud)

结果:

['Hello, my name is blabla', 'I am 30 years old', 'I have two kids']
Run Code Online (Sandbox Code Playgroud)

我无法让它工作。

使用docx2txt这里的模块: github链接

只有一个进程命令,它返回 docx 文件中的所有文本。

我也希望它保留特殊字符,如 ":\-\.\,"

python python-2.7 python-docx

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