Python中文
首页
教程
问答
标签
搜索
登录
注册
无法将int转换为string
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我试图运行此代码,但它给我以下错误:</p> <pre><code>Traceback (most recent call last): File "C:/Users/Admin/Desktop/gess.py", line 29, in <module> print('arasworia, chemi chafiqrebuli cifri iyo ' + cif) TypeError: Can't convert 'int' object to str implicitly </code></pre> <p>代码如下:</p> <pre><code>import random guessTaken = 0 print(' ra gqvia? ') sax = input() cif = random.randint(1, 10) print('Gamarjoba ' + sax + ' me vfiqrob cifrs, romelic aris 1 dan 10-mde! da gaqs 3 cda ') while guessTaken < 3: print(' chaifiqre cifri') vard = input() vard = int(vard) guessTaken = guessTaken + 1 if vard < cif: print( ' Ufro dabal cifrs vfiqrob ') if vard > cif: print( ' ufro magal cifrs vqirob ' ) if vard == cif: break if vard == cif: guessTaken = str(guessTaken) print('gilocav ' + sax + 'shen gamoicane cifr ' + guessTaken + ' cdashi!') if vard != cif: cif == str(cif) print('arasworia, chemi chafiqrebuli cifri iyo ' + cif) </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>那个</p> <pre><code>cif == str(cif) </code></pre> <p>应该是</p> <pre><code>cif = str(cif) </code></pre> <p>在Python中,<code>==</code>是比较,<code>=</code>是赋值。你知道吗</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Python中是否有类似Clojure的线程宏?
10 回答
Python中是否有类似JPanel的组件?
9 回答
Python中是否有类似MATLAB的vpasolve的等价解算器
10 回答
python中是否有类似NLTK的东西不需要安装?
8 回答
python中是否有类似osgi在java中试图解决的需求?
9 回答
python中是否有类似PAM的模块?
8 回答
Python中是否有类似Perl的Data::Dumper的工具用来检查数据结构?
8 回答
python中是否有类似robocy的函数,带有重试选项?
6 回答
Python中是否有类似Rstudio的帮助部分?
5 回答
python中是否有类似ruby的索引方法?
8 回答
python中是否有类似于“perlpe”选项的内容?
8 回答
Python中是否有类似于C++ STL映射的结构?
9 回答
python中是否有类似于C中预处理器行为的工具?
8 回答
Python中是否有类似于Harmony的let关键字的内容?
2 回答
python中是否有类似于matlab中fzero的函数?
2 回答
python中是否有类似于MATLAB中peaks(N)的函数/实现?
3 回答
Python中是否有类似于Matlab的deconvblind的函数?
9 回答
Python中是否有类似于Perl中“想要”的东西
9 回答
Python中是否有类似于Perl正则表达式中的"local"变量?
8 回答
python中是否有类似于php的$$变量的语法
3 回答