Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我需要一些关于pyglatin翻译代码(python)的帮助_Python - Fatal编程技术网

我需要一些关于pyglatin翻译代码(python)的帮助

我需要一些关于pyglatin翻译代码(python)的帮助,python,Python,好的,代码是 pyg = 'ay' def word(): def new_word(): new_word = word + first + pyg print "To translate type A word or name!" original = raw_input('Enter A word:') if len(original) > 0 and original.isalpha(): def new_word(): word =

好的,代码是

pyg = 'ay'
def word():
    def new_word():
        new_word = word + first + pyg
print "To translate type A word or name!"
original = raw_input('Enter A word:')
if len(original) > 0 and original.isalpha():
    def new_word():
        word = original.lower()
        first = word[0]
        new_word = word[1 : len(new_word)] + first + pyg
    print "Translating 1 moment..."
    print "Translated view below!"
    print new_word
    print "Made by: Tobias Balentine"
else:
    print 'empty'
这是我的代码,所有东西都在工作,除了应该是翻译的部分我会告诉你我得到了什么

To translate type A word or name! 
Enter A word:Tobias 
Translating 1 moment... 
Translated view below! 
<function new_word at 0x021619F0> 
Made by: Tobias Balentine
所以这句话应该是翻译过来的,但由于某些原因,它没有显示出来,请帮助别人

pyg = 'ay'
print "To translate type A word or name!"
original = raw_input()
if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = word[0]
    new_word = word[1:] + first + pyg
    print "Translating 1 moment..."
    print "Translated view below!"
    print new_word
    print "Made by: Tobias Balentine"
else:
    print 'empty'

您定义的函数太多,甚至没有使用它们。

您的新单词函数覆盖了新单词变量。给其中一个取不同的名字。你也从来没有调用过你的函数,所以也是这样。但它会说,无论我如何重命名一个函数,它都会说它没有定义,实际上,你的整个流程都很奇怪。def word中的def new_word,当两者都未使用时?这可能要简单得多…你能帮我解释一下吗?我两周前才开始学习python