如何将数字列表转换为字母列表,Python

时间:2018-09-10 22:32:01

标签: python python-3.x list

python的新手,我正在尝试编写加密的消息

字母已被重写如下:

input = str(input('Write Text: ')) #hello world used here
input = input.lower()
output = []
for character in input:
    number = ord(character) - 97
    output.append(number)
print(output)

输出: w

print(cipher[output])

输出:

[7,4,11,11,14,-65,22,14,17,11,3]

不确定如何对应这两个...

我尝试过:

WITH CTE (Product_sku,rownumber) AS 
(
    SELECT product_sku 
    , row_number() over(order by product_sku) 
    FROM product_updates
    WHERE action = 'delete'
)

SELECT 
Delete1= cast(
    (SELECT TOP 1 
    STUFF(
        (SELECT ',''' + product_sku+'''' FROM CTE 
        WHERE cte.RowNumber BETWEEN 1 and 700 
        FOR XML PATH (''))
    , 1, 1, '') ) 
    AS varchar(8000))

... and nine more of these select statements into additional variables to allow for larger delete operations.

返回TypeError:列表索引必须是整数或切片,而不是列表

预先感谢

1 个答案:

答案 0 :(得分:0)

我认为您想要类似的东西

deciphered = [cipher[i] if i > 0 else ' ' for i in output]
print(''.join(deciphered))

请注意i>0位在其中以处理空格,这导致number为-65 ...