调整成列表.
比如是一个str。
如果程序是这样的:
names = 'lliy'
names2 = 'pop'
names.append(names2)
print(names)
他就会提示:
Traceback (most recent call last): File "C:\Users\Administrator\AppData\Roaming\JetBrains\PyCharmCE2024.2\scratches\scratch_3.py", line 3, in <module> names.append(names2) AttributeError: 'str' object has no attribute 'append'
修改为这个:(只需要在需要扩充的参数上加一个【】就可以解决啦)
names = ['lliy']
names2 = 'pop'
names.append(names2)
print(names)