Invaild语法Python Inside print 2.7.11

2024-10-01 00:31:09 发布

您现在位置:Python中文网/ 问答频道 /正文

好的,所以在print函数中是一个错误。我似乎无法摆脱的是我的代码:

def chaselect():
    print '''
Now you must choose your race '''

    while player.race == None:
        ace = raw_input('''

1. Human
2. Elf
3. Dwarf
4. Orc
 '''))
        if ace == '1':
            print 'You chose human are you sure?' 
            con = raw_input('''
1. Confirm Race
2. Read Lore
3. Go Back
 '''))

这是python2.7.11,所以我不需要打印('e.g') 现在发生的是一个语法错误发生在打印内部? 我该怎么解决这个问题?为什么会出现这样的错误呢?你知道吗


Tags: 函数代码youinputyourrawdef错误
2条回答

输入函数的括号太多。你知道吗

def chaselect():
    print '''
    Now you must choose your race '''

    while player.race == None:
        ace = raw_input('''

1. Human
2. Elf
3. Dwarf
4. Orc
''')
        if ace == '1':
            print 'You chose human are you sure?' 
            con = raw_input('''
1. Confirm Race
2. Read Lore
3. Go Back
''')

我认为你应该使用IDE(比如PyCharm,Wing IDE)。 这些编辑会发现你的打字错误。你知道吗

试试这个:

def chaselect():
    print 'Now you must choose your race '

    while player.race == None:
        ace = raw_input('1. Human \n2. Elf \n3. Dwarf \n4. Orc\n')
        if ace == '1':
            print 'You chose human are you sure?' 
            con = raw_input('\n1. Confirm Race\n2. Read Lore\n3. Go Back')

相关问题 更多 >