Home  >  Article  >  Backend Development  >  sirius's python study notes (1)

sirius's python study notes (1)

黄舟
黄舟Original
2016-12-20 16:50:291595browse

1. You can simply judge whether a string is an integer value through the try...except statement, such as the routine

x = raw_input('>')

try:

PRint int(x)

except ValueError:

Return None

2. The append function can also be used to add tuples, as follows

x = ('1','2')

y= []

y.append(x)

print y

The result is: [('1','2')]

The above is the content of sirius's python study notes (1). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:python binary searchNext article:python binary search