【发布时间】:2015-01-03 02:30:32
【问题描述】:
我正在制作一个程序,如果用户输入文本,它会将所有大写字母转换为小写:
def lowerChar(char):
if ord(char) >= 65 and ord(char) <= 90:
char = int(ord(char)) + 32
char = (chr(char))
return print(char)
else:
return print(char)
def lowerString(string):
x = len(string)
for i in range(x):
char = string[0 + i]
lowerChar(char)
result = ""
result = result + lowerChar(string[i])
string = input("type")
lowerString(string)
错误是:
Traceback (most recent call last):
File "C:\Python34\njn.py", line 24, in <module>
lowerString(string)
File "C:\Python34\njn.py", line 19, in lowerString
result = result + lowerChar(string[i])
TypeError: Can't convert 'NoneType' object to str implicitly
任何帮助将不胜感激。
【问题讨论】:
-
这个问题是关于实现的,属于 Stack Overflow (实现问题,例如代码修复(请在 Stack Overflow 上提问))
标签: python python-3.x