Python中文
首页
教程
问答
标签
搜索
登录
注册
无法在python中使用int(raw_input())
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在一个编码竞赛中尝试这个<a href="http://www.codechef.com/DEC12/problems/GRANAMA" rel="nofollow">problem</a>。我相信我已经解决了问题,但在接受意见方面有一些问题。帮帮我:</p> <hr/> <p>输入</p> <p>输入的第一行包含一个整数T,表示测试用例的数量。下面是对T测试用例的描述。每个测试用例由一行组成,其中包含两个空格分隔的字符串R和S,表示两个配方。</p> <hr/> <p>现在,我已经对这个问题进行了编码,它似乎可以工作,但是每当我直接复制粘贴输入值时,它就不能通过给出这个错误消息来工作</p> <hr/> <pre><code>T= int(raw_input()) ValueError: invalid literal for int() with base 10: '3\nalex axle\nparadise diapers\nalice bob' </code></pre> <hr/> <p>每当我试图提交问题时,就会收到一条错误消息。可能他们也在复制粘贴输入值并检查输出。我的代码框架是这样的</p> <hr/> <pre><code>def whetherGranama(str1,str2): return "NO" #can't give the implementation out yet T= int(raw_input()) ans=[] for x in range(0,T): s=raw_input() s1,s2=s.split() ans.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(whetherGranama(s1,s2)) for elem in ans: print elem </code></pre> <hr/> <p>如何修复<code>\n</code>错误?我认为整个输入被看作一个字符串。</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>拆分输入,使用拆分列表提取进程的整数</p> <pre><code>s = raw_input() s = s.split() T = int(s[0]) ans=[] for st in s[1:]: //Do the rest </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
在python3中使用Scipy pearsonr函数
2 回答
在Python3中使用scipy对多个lorentzian进行数据拟合
3 回答
在Python3中使用Script=argv
9 回答
在python3中使用selenium webdriver进行未解析的回溯
8 回答
在python3中使用selenium和phantomjs的网页截图之前如何等待?
4 回答
在Python3中使用Selenium和Requests模块从网页获取文件
6 回答
在python3中使用SIGINT终止函数
3 回答
在Python3中使用SIGTERM时,允许进程完成而不是中断
2 回答
在python3中使用smtplib发送XML内容
6 回答
在python3中使用socket库(RFCOMM模式)重新连接蓝牙设备?
2 回答
在python3中使用sounddevice和numpy编写wav文件
5 回答
在python3中使用Sqlalchemy插入MySQL查找类型错误的原因
6 回答
在python3中使用sqlite、pandas和sqlalchemy很难让rollback工作
1 回答
在python3中使用SQLite的FTS3/4
4 回答
在Python3中使用struct.calcsize()和len()有区别吗?
4 回答
在python3中使用substring函数时发生TypeError
6 回答
在Python3中使用Tkinter entry小部件写入串行设备
4 回答
在python3中使用tkinter时,如何在每次按下函数时获得运行该函数的按钮?
5 回答
在python3中使用tkinter的子帧
1 回答
在Python3中使用tryexcept块时,如何避免使用未初始化的变量?
5 回答