我如何将原诗转换成已转换的诗
它应该将cubits
转换为feet
原诗:
"So make yourself an ark of cypress wood; make rooms in it and coat it with pitch inside and out. This is how you are to build it: The ark is to be 300 cubits long, 50 cubits wide and 30 cubits high. (Genesis 6:14-15)"
转换诗:
"So make yourself an ark of cypress wood; make rooms in it and coat it with pitch inside and out. This is how you are to build it: The ark is to be 450 feet long, 75 feet wide and 45 feet high. (Genesis 6:14-15)"
记下每个单词,然后检查值
差不多
输出
"So make yourself an ark of cypress wood; make rooms in it and coat it with pitch inside and out. This is how you are to build it: The ark is to be 450 feet long, 75 feet wide and 45 feet high. (Genesis 6:14-15)"
您可以匹配正则表达式,并使用替换函数调整单位(并更改单位名称)
结果:
当正则表达式匹配后跟“cubits”的数字时,它调用lambda回调,解析该数字,乘以1.5,转换回整数,并用新的单位重新格式化输出
这将不得不微调为1英尺,并可以使用转换字典,如果有更多的单位转换
相关问题 更多 >
编程相关推荐