【发布时间】:2016-08-15 23:46:51
【问题描述】:
我需要知道文本中第 n 个字符的字母位置,我阅读了 this question 的 answer,但它不适用于我的 Python 3.4
我的程序
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 22 12:24:15 2016
@author: Asus
"""
import string
message='bonjour'
string.lowercase.index('message[2]')
它也不适用于 ascii_lowercase 而不是小写。
错误信息
runfile('C:/Users/Asus/Desktop/Perso/WinPython-64bit-3.4.3.4/python-3.4.3.amd64/Scripts/ESSAI.py', wdir='C:/Users/Asus/Desktop/Perso/WinPython-64bit-3.4.3.4/python-3.4.3.amd64/Scripts') Traceback(最近一次调用最后一次):
文件“”,第 1 行,在 runfile('C:/Users/Asus/Desktop/Perso/WinPython-64bit-3.4.3.4/python-3.4.3.amd64/Scripts/ESSAI.py', wdir='C:/Users/Asus/Desktop/Perso/WinPython-64bit-3.4.3.4/python-3.4.3.amd64/Scripts')
文件 "C:\Users\Asus\Desktop\Perso\WinPython-64bit-3.4.3.4\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", 第 685 行,在运行文件中 execfile(文件名,命名空间)
文件 "C:\Users\Asus\Desktop\Perso\WinPython-64bit-3.4.3.4\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", 第 85 行,在 execfile 中 exec(compile(open(filename, 'rb').read(), filename, 'exec'), 命名空间)
文件 "C:/Users/Asus/Desktop/Perso/WinPython-64bit-3.4.3.4/python-3.4.3.amd64/Scripts/ESSAI.py", 第 11 行,在 string.lowercase.index('message2')
AttributeError: 'module' 对象没有属性 'lowercase'
【问题讨论】:
标签: python-3.x alphabet