在PyDev中连接字符串和整数而不是抛出错误

时间:2012-12-11 16:26:36

标签: python exception python-2.7 pydev

import sys
class test1:
    def __init__(self) :
        print"intialized"

    def yrt(self):
        try:
            name="gokl"
            age="24"
            address="hjk"
            pincode=516101
            #print "My name is %s,and my age is %s, my address is %s and my pincode is " %(name,age,address)
            **print name+pincode**
        except Exception, hj:
            sys.exit(1)

if __name__ == "__main__":
    gh=test1()
    try:
        gh.yrt()
    except Exception, ex :
        sys.exit(1)
    sys.exit(0)

1 个答案:

答案 0 :(得分:0)

你明确地抓住了这个错误并使其无声。如果你想抛出它,你就不应该抓住它。