我们知道Python元组是不可变的,很好。当我试图改变元组的引用时,我得到一个异常,如预期的那样。什么是不期望的,组件是否被改变,而不管什么异常,但我会认为元组的不变性保证对象不会变化。 这是一个错误,功能还是PEP? In [6]: x=([1],)
In [7]: type(x)
Out[7]: tuple
In [8]: x[0]+=[2,3]
-------------------
我有这样的代码: count = 0
for line in lines:
#do something with line
#do something more with line
#finish doing that thing with line
count = count + 1
if count % 10000 == 0:
嗨,这是更多的风格问题。我有一个小脚本,用套筒的作品,我有常数(我知道他们是不是真正的常数,而是heyy,至少他们是在首都),其申报的一些属性,
# Port address for the serial port to read the weight from
PADDR = '/dev/ttyUSB0'
# socket address uri, backlog, and buffer