Reverse Integer leetcode python
2015-12-08 20:47
369 查看
class Solution(object): def reverse(self,x): """ :param x:int :return: int """ max_num=2147483647 min_num=-2147483648 flag=0 if x<0: flag=1 x=-x if flag==0: if int(str(x)[::-1])>max_num or int(str(x)[::-1])<min_num: return 0 else: return int(str(x)[::-1]) else: if int(str(x)[::-1])>max_num or int(str(x)[::-1])<min_num: return 0 else: return -int(str(x)[::-1]) p=Solution() print p.reverse(1534236469)
相关文章推荐
- python之C扩展
- python中的那些“神器”
- Python if else for while 语句控制 【整理】
- 七牛---关于Python SDK的各种Demo
- 孤华暗香的Python Spider,Updating
- python pillow模块
- 机器学习Python环境安装
- (转载) Python教程
- NLP python widely used toolkits
- python PIL 处理图片的模快 Image类
- Python 抓取【参考消息网站】的新闻
- 【转载】python json
- Python variable 作用域和初始化
- 【python游戏编程之旅】第七篇---pygame中的冲突检测技术
- 反转字符串--C和Python
- Python 基础【第六篇】字典
- python中,一个函数想使用另一个函数中的变量
- Python 基础【第五篇】元组和列表
- python实战系列之ip地址排序问题(二)
- Python序列切片的注意事项