正如下面的示例所示,我想将r与包含希腊字母的字符串参数连接起来,以避免unicode错误
book = xlrd.open_workbook(r'C:\a_directory_with_greek_letters_inside.xlxs')
但是在此代码中,该函数未按我期望的那样连接r和字符串:
url='C:\a_directory_with_greek_letters_inside.xlxs'
def fnc(arg):
book = xlrd.open_workbook(r+arg))
return book
fnc(url)
我该如何解决?
rf'{arg}'
赞:
url='C:\a_directory_with_greek_letters_inside.xlxs' def fnc(arg): book = xlrd.open_workbook(rf'{arg}') return book fnc(url)