First of all, the line
AES_KEY = bytearray(bbb, 'utf-8')
must be removed in the Python code to derive the same key as in the C# code.
Then the problem you describe can be reproduced: The C# code returns e.g. for the base64 encoded IV J223ULe3Xf6PX1KfNVmEiw== and the plaintext and key posted by you the following ciphertext:
O5EBcIB987RNfZ41RbvRThmlEyP2RxkDCuGWQiajkDY=
while the Python code generates this ciphertext:
O5EBcIB987RNfZ41RbvRTg==
The reason is an already known bug in pypkcs7 (issue #1) which makes this package practically unusable, because the padding generally does not comply with the PKCS7 definition anymore (specifically if the plaintext before padding has a length that is an integer multiple of the block size (16 bytes for AES)).
So you need a different PKCS7 implementation. Fortunately PyCryptodome provides a padding module (not available in legacy PyCrypto). With the following change
#from pkcs7 import PKCS7Encoder
from Crypto.Util.Padding import pad
...
#encoder = PKCS7Encoder()
#padded_text = encoder.encode(secret_text)
padded_text = pad(secret_text.encode('utf8'), 16).decode('utf8')
the same ciphertext is generated as by the C# code (by the way, the decoding can actually be omitted, because the encryption process encodes the ciphertext again; I have kept this only with regard to a comparison with the old implementation).
As a side note, the key can be more easily derived with:
hash = hashlib.sha256(bbb.encode('utf8')).digest()
AES_KEY = hash[:15] + hash[:16] + b"\0"
PKCS7Encoder. Also missing for both codes are complete samples to reproduce the problem (ciphertext without plaintext and key don't help much). Please post an MCVE.arrayis not defined). Currently you are using a 32 byte key with 0 values (array_bbb).array_bbb_2is not used at all. No idea what you want to achieve.array_bbb_2) to 0-15 (array_bbb). In the second copy operation you copy 0-15 (array_bbb_2) to 15-30 (array_bbb). Thereby the last byte of the first copy operation is overwritten. Is this really how it should be?