python输出不带引号的字符串_如何返回不带引号的字符串Python 3

一篇关于Python中如何从十进制转换为Bukiyip数制,并在输出时不包含引号的教程。文章指出,当直接在解释器中输出或使用repr()函数时,字符串会显示其调试友好的形式,包括引号。解决方案是直接打印变量,而不是它的repr()表示。
摘要由CSDN通过智能技术生成

I've got to write a single-input module that can convert decimals to Bukiyip (some ancient language with a counting base of 3 or 4). For the purpose of the assignment, we only need to work with base 3.

I've written some code that does this, but it returns my Bukiyip number with quotes, leaving me with an answer such as '110' for 12.

Please help me understand how to work around this? I'm new to Python and keen to learn so explanations will be really appreciated.

def bukiyip_to_decimal(num):

convert_to_string = "012"

if num < 3:

return convert_to_string[num]

else:

return bukiyip_to_decimal(num//3) + convert_to_string[num%3]

I've also tried the following, but get errors.

else:

result = bukiyip_to_decimal(num//3) + convert_to_string[num%3]

print(int(resu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值