library(stringdist)
stringdistmatrix(df, df) == 0
# [,1] [,2] [,3]
#[1,] TRUE TRUE FALSE
#[2,] TRUE TRUE FALSE
#[3,] FALSE FALSE TRUE
我不知道如何修复我的代码。
答案 0 :(得分:0)
您忘记了函数中的return语句,这可能就是问题
答案 1 :(得分:0)
下面你会找到一些有用的评论来解决你的问题:
import time as t
t = t.time # Don't name this the same as your time library
# Also use t.time() instead of t.time
starttime = t
def calcprod():
prod = 1
for i in range(1, 1000000):
prod = prod * i
# return a value here (hint: cast the result to a string)
p = calcprod()
print("The result is %s digits" % (str(len(p))))
endtime = t # This assigns the same value to 'endtime' as starttime.
# You need to measure the current time again.
# How can you do this?
print("It took %s seconds to calculate" % (starttime - endtime))
# Does it make sense to calculate starttime-endtime?
# Which one is the bigger value?