我如何计算句子中的单词?我正在使用Python.
例如,我可能有字符串:
string = "I am having a very nice 23!@$ day. "
Run Code Online (Sandbox Code Playgroud)
这将是7个字.我在每个单词之后/之前以及涉及数字或符号时随机数量的空格都遇到了问题.
在这个问题上,它表示前10,000个税收没有征税,接下来的20,000个税收10%,接下来的40,000个税率20%,而前70,000个税率30%.我对python很新,但这是我到目前为止所做的.我不确定我哪里出错了.我认为这是因为我没有定义"税"变量,但我不确定.任何帮助将非常感激.谢谢!
**如果用户输入负数并且我不确定如何将其添加到我的for循环中,则代码也必须终止.
def income(drach):
for drach in range(10000):
tax = 0
for drach in range(10000 , 30000):
tax = ((drach - 10000)*0.1)
for drach in range(30000 , 70000):
tax = ((drach - 30000)*0.2) + 2000
for drach in range(70000 , 10**999):
tax = ((drach - 70000)*0.3) + 10000
print tax
Run Code Online (Sandbox Code Playgroud) 这是我的有问题的查询:
string_agg(product_type, "|" order by product_type desc) over(partition by email, processed_date) as full_basket
Run Code Online (Sandbox Code Playgroud)
我在订购 string_agg 时遇到问题。问题在于,一个“篮子”显示“product_a | Product_b”,另一个“篮子”可能显示“product_b | Product_a”,这是完全相同的事情。
当我运行此查询时,BigQuery 给出以下错误:“[14:1] 处的分析函数不支持参数中的 ORDER BY”
关于如何订购有什么想法吗?
我想要模拟一个石头剪刀游戏,这是我到目前为止.它不是让我在scoregame
函数中输入字母.我怎样才能解决这个问题?
def scoregame(player1, player2):
if player1 == R and player2 == R:
scoregame = "It's a tie, nobody wins."
if player1 == S and player2 == S:
scoregame == "It's a tie, nobody wins."
if player1 == P and player2 == P:
scoregame = "It's a tie, nobody wins."
if player1 == R and player2 == S:
scoregame = "Player 1 wins."
if player1 == S and player2 == P:
scoregame = "Player 1 wins."
if player1 == …
Run Code Online (Sandbox Code Playgroud) 我一直在接受ZeroDivisionError
.我的代码如下.什么似乎是我的问题?
def number(x):
for i in range(x):
if x%i == 0:
print(i)
Run Code Online (Sandbox Code Playgroud)