社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

Katana(python):编码问题还是bug?

Ellis Hogan • 5 年前 • 1598 次点击  

好的,这是密码。我不打算在日志中键入错误。不需要复制代码。它的基本意思是存在一个问题,即“l”不是int类型。

def i_am_here(path):
  print(path)
  lst = []
  num = []
  x = 0
  y = 0
  for i in path:
    try: 
        int(i)
        num.append(int(i))
    except ValueError:
        if i == 'r' or i == 'R':
            new = ''.join(num)
            lst.append(new)
            lst.append('r')
            num = []
        if i == 'L' or i == 'l':
            new = ''.join(num)
            lst.append(new)
            lst.append('l')
            num = []
  new = ''.join(num)
  lst.append(new)
  lst = lst[1:len(lst)]
  print(lst)
  for i in range(len(lst)):

    if lst[i] == 'r':
        print(lst[i+1])

enter image description here

好的,所以我99%确定这只是一个错误,当我使用:

for i in path:
    try: 
        int(i)
        num.append(int(i))
    except ValueError:
        if i == 'r' or i == 'R':

            lst.append(num)
            lst.append('r')
            num = []
        if i == 'L' or i == 'l':

            lst.append(num)
            lst.append('l')
            num = []

一切正常。有什么想法吗?我本来打算提交一张发行票,但在提交之前我想我可能会问。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43155
 
1598 次点击  
文章 [ 2 ]  |  最新文章 5 年前