Буду признателен за любую помощь.
Вот код, который выдает ошибку:
Код: Выделить всё
import subprocess
username = input('Please enter user name: ')
command = f'Get-ADPrincipalGroupMembership -Identity {username} | select name, GroupCategory, GroupScope'
result = subprocess.run(['powershell.exe', command], capture_output=True, text=True)
r = result.stdout
Код: Выделить всё
Exception in thread Thread-1 (_readerthread):
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1494, in _readerthread
buffer.append(fh.read())
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\encodings\cp1255.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8c in position 1263: character maps to
Я попробовал присвоить переменной буквы иврита и распечатать их, и все в порядке.
Так что, возможно, это какой-то другой специальный символ, о котором я понятия не имею, какой именно .
Подробнее здесь: https://stackoverflow.com/questions/791 ... dec-issues
Мобильная версия