Найти - Пользователи
Полная версия: Ошибка в скрипте
Начало » Python для новичков » Ошибка в скрипте
1
satfan
Python 3.10 64-bit
——————–
Есть такой скрипт:
 from ipytv import playlist
file = "C:\Users\Пк\Desktop\123.m3u, encoding='utf-8'"
pl = playlist.loadf(file)
print(pl.length())

Выдаёт ошибку:
File “C:\Users\Пк\Desktop\Test.py”, line 3
file = “C:\Users\Пк\Desktop\123.m3u, encoding='utf-8'”
^
SyntaxError: (unicode error) ‘unicodeescape’ codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
——————-
Или так в проверке онлайн:
Line 3
SyntaxError: Non-ASCII character ‘\xd0’ in file t.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
——————-
Скрипт брал здесь: https://pypi.org/project/m3u-ipytv/
Подскжите как исправить ?
py.user.next
Ты забыл букву r поставить перед строкой. Последовательность \U в строке запускает разбор юникодового символа.
  
>>> 'a\U00000040b'
'a@b'
>>> 
>>> r'a\U00000040b'
'a\\U00000040b'
>>>
ZerG
Тут вопрос что ты указываешь кодировку файла utf-8 под виндой
попробуй cp1251 или cp866

https://ctrl.vi/i/mlb17zxCq
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB