What does the [] mean? Also how can I identify variables as empty arrays in python? 开发者_开发技巧Thanks!
perl: xcoords = ()
How do I translate that?
[] - is an empty list in Python and is the same as calling list() e.g. [] == list() To check that list is empty you can use len(l) or:
listV = [] # an empty list
if listV:
# do something if list is not empty
else:
# do something if list is really empty
To read more about list you can use the following link
Lists are like C++ arrays with some difference. One of difference is they can cary different types even lists. to check if lists is empty
lists = []
len(lists)
lists[0]= "More of me"
len(lists)
More check Python official tutorial and above Docs
精彩评论