第一个问题:为什么会出现关于“非ASCII”的警告?要求我确定:- - 编码:cp1252 - - 第二个问题:代码下方的 KeyError 消息。
谢谢大家,非常,非常。我重视您的回答和建议
##Largest palindrome product Problem 4
##A palindromic number reads the same both ways. The largest palindrome made from the
##product of two 2-digit numbers is 9009 = 91 × 99.
##Find the largest palindrome made from the product of two 3-digit numbers.
def is_palindrome(number):
return str(number) == str(number) [ : : -1]
if __name__ == "__main__":
print ( " { } and { } => { } ".format(*max( (i, j, i*j )
for i in range(1000, 900, -1)
for j in range(1000, 900, -1)
if is_palindrome (i*j))))
##Traceback (most recent call last):
## File "C:/Python27/Euler prob 4.py", line 11, in <module>
## for i in range(1000, 900, -1)
##KeyError: ' '