python - 将 toolz.pipe 与方法一起使用
问题描述
我有一个pipe
要从 toolz 中清理的字符串。但似乎我无法弄清楚如何str.replace
在管道中应用该方法。这是一个例子:
x = '9\xa0766'
from toolz import pipe
import unidecode
# Can do like this, but don't want to use nesting.
int(unidecode.unidecode(x).replace(" ", ""))
# Wan't to try to do like this, with sequence of steps, applying transformations on previous output.
pipe(x,
unidecode.unidecode,
replace(" ", ""),
int
) # DON'T WORK!!
# NameError: name 'replace' is not defined
更一般地,请注意 的输出unidecode.unidecode
是一个字符串。所以我希望能够对其应用一些字符串方法。
pipe(x,
unidecode.unidecode,
type
) # str
用管道可以吗?
解决方案
推荐阅读
- flutter - 使用 Flutter Checkbox() 并从 Firestore 获取初始值
- c# - 无法正确配置 WCF Restful/json 端点
- python - 错误:OpenCV(4.1.2) (-215:Assertion failed) image.channels() == 1 || image.channels() == 3 || image.channels() == 4 在函数 'cv::imwrite_'
- javascript - 什么 (int & 1) != 0 是什么意思
- php - Mine Composer Autoload PSR-4 不工作
- bash - Bash - 磁盘利用率通知
- ios - 为 UITableView 标题文本设置 accessibilityLabel
- python - DIY 剪辑而不是使用 numpy.clip
- c# - 将 azure keyvault 机密 json 反序列化为 MicrosoftIdentityOptions
- php - 如何在一个 gcloud 应用上运行多个页面