更新选项=(选项%6)和#x2B;1从python 2到python 3

更新选项=(选项%6)和#x2B;1从python 2到python 3,python,typeerror,Python,Typeerror,我有一个程序需要choice=(choice%6)+1,这是我用python 2编写的。当我尝试在Python3中运行它时,我得到了TypeError:在字符串格式化过程中并没有转换所有参数。我刚刚更新到Python3,并且修复了这个程序中的大部分内容,但是我似乎无法修复这个问题,所以Python3将接受它。我对Python比较陌生,在Python3变更日志中找不到简单的答案。感谢您的帮助!谢谢也许,您的程序中有类似于choice=input(“输入您的选择”)的内容。您必须知道,在Python

我有一个程序需要choice=(choice%6)+1,这是我用python 2编写的。当我尝试在Python3中运行它时,我得到了TypeError:在字符串格式化过程中并没有转换所有参数。我刚刚更新到Python3,并且修复了这个程序中的大部分内容,但是我似乎无法修复这个问题,所以Python3将接受它。我对Python比较陌生,在Python3变更日志中找不到简单的答案。感谢您的帮助!谢谢

也许,您的程序中有类似于
choice=input(“输入您的选择”)
的内容。您必须知道,在Python2中,您在
input
中输入的任何内容都被直接计算为Python代码。所以如果你输入一个“5”,你就会得到数字5

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> choice = input()
42
>>> type(choice)
<type 'int'>

要将其转换为一个数字,只需执行
choice=int(choice)

很可能,您的程序中有类似于
choice=input(“输入您的选择”)
。您必须知道,在Python2中,您在
input
中输入的任何内容都被直接计算为Python代码。所以如果你输入一个“5”,你就会得到数字5

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> choice = input()
42
>>> type(choice)
<type 'int'>

要将其转换为一个数字,只需执行
choice=int(choice)

很可能,您的程序中有类似于
choice=input(“输入您的选择”)
。您必须知道,在Python2中,您在
input
中输入的任何内容都被直接计算为Python代码。所以如果你输入一个“5”,你就会得到数字5

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> choice = input()
42
>>> type(choice)
<type 'int'>

要将其转换为一个数字,只需执行
choice=int(choice)

很可能,您的程序中有类似于
choice=input(“输入您的选择”)
。您必须知道,在Python2中,您在
input
中输入的任何内容都被直接计算为Python代码。所以如果你输入一个“5”,你就会得到数字5

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> choice = input()
42
>>> type(choice)
<type 'int'>
要将其转换为数字,只需在Python 3中执行
choice=int(choice)

即可
input()
返回一个字符串,因此需要额外的
int()
调用
input()
。请参见Python 3中的
input()
返回一个字符串,因此需要额外的
int()
调用
input()
。请参阅Python 3中的
input()
返回字符串,因此需要额外的
int()
调用
input()
。请参阅Python 3中的
input()
返回字符串,因此需要额外的
int()
调用
input()
。请参阅