简体   繁体   中英

Can you use "\" in a dictionary inside Python?

I'm creating a variation of the vigenere cipher using all the ASCII characters using a dictionary. The first few lines are okay, but then I get an error for the value 3. vigenereDictionary = { "@": "0", "%": "1", "+": "2", "\": "3", "/": "4", ... I want to have it so that when a user types \ it will output/take the value 3, however, I understand backslash is a special character, is there any way to implement this.

" 它是字符串的转义字符,请尝试使用 "\",它会转义反斜杠本身。 – ChrisOram "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM