用random.randint函数时 报错 'str' object cannot be interpreted as an integer问题

range()仅将int值用作参数。所以会报错。

原:

n=input("輸入")

解决方法:

1.eval()

n=eval(input("輸入"))

2.用int()

n=int(input("輸入"))

用random.randint函数时 报错 'str' object cannot be interpreted as an integer问题

原文地址:https://www.cnblogs.com/claudia529/p/12078445.html

时间: 2024-08-28 03:27:55

用random.randint函数时 报错 'str' object cannot be interpreted as an integer问题的相关文章

python报错'str' object is not callable

>>> x=1.235 >>> int(x) 1 >>> str="fsgavfdbafdbntsbgbt" >>> len(str) 19 >>> >>> x=987456123 >>> str(x) 会报错'str' object is not callable. str()是系统自带的,你不能在用它的时候自己同时定义一个别的叫做str的变量,这样会冲突.

oc调用c++接口时 报错 Undefined symbols for architecture i386:

当在oc中调用c++中的方法时,发现说c++中的方法没定义或是找不到 Undefined symbols for architecture i386: "_desTYData", referenced from:-[TuYoo encryptParametersWithDict:] in libtuyoo.a(TuYoo.o)ld: symbol(s) not found fo 记得c++中的方法定义是要这样定义的 extern"C" { const char *d

VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法

正常情况下在data里面都有做了定义 在函数里面进行赋值 这时候你运行时会发现,数据可以请求到,但是会报错 TypeError: Cannot set property 'listgroup' of undefined 主要原因是: 在 then的内部不能使用Vue的实例化的this, 因为在内部 this 没有被绑定.可以看下 Stackoverflow 的解释: 解决办法: 1.用ES6箭头函数,箭头方法可以和父方法共享变量 2.在请求axios外面定义一下 var that=this 问题

WPF加载Winform窗体时 报错:子控件不能为顶级窗体

一.wpf项目中引用WindowsFormsIntegration和System.Windows.Forms 二.Form1.Designer.cs 的 partial class Form1 设置为:public partial class Form1 三.代码如下: XXXX.Form1 Zhuwindow = new XXXX.Form1(); Zhuwindow.TopLevel = false; Zhuwindow.FormBorderStyle = System.Windows.Fo

Swift 给UITableView 写extension 时 报错 does not conform to protocol 'UITableViewDataSource'

那是因为你没有实现 数据源和代理方法 实现下就好了 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { return UITableViewCell() } Sw

解决 vs2010 联接sql 2005 时 报错未能加载文件或程序集“Microsoft.SqlServer.Management.Sdk.Sfc

http://blogs.msdn.com/b/sqlnativeclient/archive/2008/05/30/sqlncli-msi-for-sql-server-2008.aspx 关键是这位老兄的回复,第三条 DavidDmsVcp - MSFT 6 Mar 2013 9:13 AM # You can find the sqlncli.msi in a SQL Server feature pack: Microsoft SQL Server 2008 SP3 Feature Pa

全局安装的 webpack运行时 报错 Error: Cannot find module 'webpack' ......

全局安装的webpack   安装指令如下 cnpm install wepack -save-dev -g 但是 在我的项目空间运行webpack指令的时候 会报如下错误 为了方便抓取{ Error: Cannot find module 'webpack' at Function.Module._resolveFilename (module.js:527:15) at Function.Module._load (module.js:476:23) at Module.require (m

VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法

created() { var that=this axios.get('http://jsonplaceholder.typicode.com/todos') .then(function (res) { // handle success // console.log(res); that.todos = res.data }) .catch(function (error) { // handle error console.log(error); }) .finally(function

oracle创建包后执行报错:object omgmig.test_package is invalid.

今天学习了一下oracle的包的写法,然后碰到这么个问题.包声明和包主体都正确,但是就是执行报错:object omgmig.test_package is invalid. 这是会报错的sql,看起来都正常对吧..但是就是会报错 --包声明 create package omgmig.test_package as procedure show1; end omgmig.test_package; --包体 create package body omgmig.test_package as