Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数组(列表),我想检查它的大小是否等于 1,如果是,那么它需要添加一个新的,如图所示。
## If appended data = 1 then append the new line: if appended_data == 1: appeneded_data.append("") ## Add a new line if appended data has a size of 1
应该是一件相当简单的事情,但我无法解决:S
有任何想法吗?
使用它的len()功能:
len()
if len(appended_data) == 1:
简短演示:
>>> len([]) 0 >>> len([1]) 1 >>> len([1, 2]) 2