python - 使 for 循环附加在所有数据集上
问题描述
我正在尝试将 for 循环附加到范围内的所有数据集上,(0,8675)
但仅使用 1 行时它会不断出错
def convert_emoticons(text):
for emot in EMOTICONS:
text = re.sub(u'('+emot+')', "_".join(EMOTICONS[emot].replace(",","").split()), text)
return text
text = (dataset['posts'][0])
convert_emoticons(text)
解决方案
尝试使用emot
:
def convert_emoticons(text):
for emot in EMOTICONS:
text = re.sub(u'('+emot+')', "_".join(emot.replace(",","").split()), text)
return text
text = (dataset['posts'][0])
convert_emoticons(text)
推荐阅读
- php - 如何上传 csv 文件和 password_hash
- one-time-password - 在 React-native EXPO 应用程序中实现 OTP 设置
- python - 删除熊猫数据框条目中的重复字符串
- javascript - 如何仅使用 js 聚焦当前窗口?
- python - 在屏幕旋转时移动鼠标指针
- ruby - ruby 控制器参数是否已转义?
- functional-programming - sml 中的空元组
- api - 方法的实现不可用 错误
- apache - .htaccess 自定义文件夹中的 php url
- typescript - 返回接口的实例而不声明变量而不进行强制转换