我有以下声明,
sentence = " Hi my goal is to achieve highest score in mathematics, but my friend has scored some how more. and now i am myself depressed.
Run Code Online (Sandbox Code Playgroud)
我想将所有“我的”替换为“代词”,如下所示。我不想取代我自己就是想保持自己的状态
预期输出为:
Hi PRONOUN goal is to achieve highest score in mathematics, but PRONOUN friend has scored some how more. and now i am myself depressed.
Run Code Online (Sandbox Code Playgroud)
我已经尝试在python中遵循正则表达式
regex = re.sub(r'\\bmy$')
Run Code Online (Sandbox Code Playgroud) 我有一个文本,我在句子中有一些数字,我只想将数字转换为单词格式。我该如何解决这个问题。我已经为此编写了一个代码,但这不起作用,因为我将文本传递给“函数”而不是数字。我怎么做
我试过下面的代码。
import num2words
def convert_num_to_words(utterance):
utterance = num2words(utterance)
return utterance
transcript = "If you can call the merchant and cancelled the transaction and confirm from them that they will not take the payment the funds will automatically be credited back into your account after 24 hours as it will expire on 11/04 Gemma"
print(convert_num_to_words("transcript"))
Run Code Online (Sandbox Code Playgroud)
预期结果是
“如果您可以致电商家并取消交易并从他们那里确认他们不会接受付款,那么资金将在 24 小时后自动记入您的账户,因为它将在 11/04 Gemma 到期”
即文本中的数字 24 应转换为单词(二十四)
考虑一下我编写的使用和if else声明的代码
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int a = 5;
if(a)
{
printf("if %d\n" , ++a);
}
else
printf("else %d\n" , a);
}
Run Code Online (Sandbox Code Playgroud)
如果我设置int a = 5它打印输出"如果6"
但如果我设置int a = 0它打印值"else 0"
为什么会发生什么原因?