Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· openaiHugging Face Suzhen/CodeChat

ما هذا الخطأ Traceback (most recent call last): File…

  1. User

    ما هذا الخطأ Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), main.dict) File "", line 6 video_urls = input(“Enter urls separated by space: “).split() ^ SyntaxError: invalid character '“' (U+201C)

    [Program finished]

  2. Assistant

    الخطأ هو SyntaxError والذي يعني أن هناك خطأ في صياغة الكود. في هذه الحالة، الخطأ هو invalid character '“' (U+201C) والذي يعني أن هناك حرف غير صالح في السطر 6 في الكود. يجب استخدام علامات الاقتباس الصحيحة في الأسطر التي تستخدم النصوص مثل input() و print(). في هذه الحالة، يجب استخدام علامات الاقتباس المزدوجة "" بدلا من علامات الاقتباس المستخدمة في السطر الخاطئ.

  3. User

    هذا هو الكود صحح الخطا import requests from bs4 import BeautifulSoup import os from tqdm import tqdm

    video_urls = input(“Enter urls separated by space: “).split() if not os.path.exists(“tiktok_videos”): os.makedirs(“tiktok_videos”)

    for url in tqdm(video_urls): try: res = requests.get(url) soup = BeautifulSoup(res.text, ‘html.parser’) video_url = soup.find(‘video’).attrs[‘src’] with open(‘temp_video.mp4’, ‘wb’) as f: f.write(requests.get(video_url).content) video_name = url.split(”/”)[-1] + “.mp4” with open(f"tiktok_videos/{video_name}“, ‘wb’) as f: f.write(requests.get(video_url).content) except: print(f"Failed to download video at {url}”)

    print(“Finished downloading videos!”)

  4. Assistant

    import requests from bs4 import BeautifulSoup import os from tqdm import tqdm

    video_urls = input("Enter urls separated by space: ").split() if not os.path.exists("tiktok_videos"): os.makedirs("tiktok_videos")

    for url in tqdm(video_urls): try: res = requests.get(url) soup = BeautifulSoup(res.text, 'html.parser') video_url = soup.find('video').attrs['src'] with open('temp_video.mp4', 'wb') as f: f.write(requests.get(video_url).content) video_name = url.split("/")[-1] + ".mp4" with open(f"tiktok_videos/{video_name}", 'wb') as f: f.write(requests.get(video_url).content) except: print(f"Failed to download video at {url}")

    print("Finished downloading videos!")

  5. User

    وما الخطأ هنا أيضاً Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), main.dict) File "", line 7 video_urls = input(“Enter urls separated by space: “).split() ^ SyntaxError: invalid character '“' (U+201C)

    [Program finished]

  6. Assistant

    الخطأ هنا هو SyntaxError وهو نفس الخطأ السابق والذي يشير إلى أن هناك حرفًا غير صالح في السطر 7. يجب استخدام علامات الاقتباس الصحيحة في الكود. يمكن حل هذا الخطأ بتعديل علامات الاقتباس المستخدمة في input() واستخدام علامات الاقتباس المزدوجة "" بدلاً منها.

    الكود بعد التعديل:

    import requests 
    from bs4 import BeautifulSoup 
    import os
    from tqdm import tqdm 
    
    video_urls = input("Enter urls separated by space: ").split()
    if not os.path.exists("tiktok_videos"):
        os.makedirs("tiktok_videos")
    
    for url in tqdm(video_urls):
        try:
            res = requests.get(url)
            soup = BeautifulSoup(res.text, 'html.parser')
            video_url = soup.find('video').attrs['src']
            with open('temp_video.mp4', 'wb') as f:
                f.write(requests.get(video_url).content)
            video_name = url.split("/")[-1] + ".mp4"
            with open(f"tiktok_videos/{video_name}", 'wb') as f:
                f.write(requests.get(video_url).content)
        except:
            print(f"Failed to download video at {url}")
    
    print("Finished downloading videos!")
    
  7. User

    و ما هذا الخطأ Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), main.dict) File "", line 6 video_urls = input(“Enter urls separated by space: “).split() ^ SyntaxError: invalid character '“' (U+201C)

    [Program finished]

  8. Assistant

    الخطأ هو SyntaxError وتم تحديده بنفس الطريقة حيث يوجد حرف غير صالح في السطر 6. الحل هو استخدام العلامات الصحيحة في الأسطر التي تحتوي على النصوص. يمكن استخدام علامات الاقتباس المزدوجة "" بدلاً من علامات الاقتباس الغير صحيحة التي تم استخدامها.

    الكود بعد التعديل:

    import requests 
    from bs4 import BeautifulSoup 
    import os
    from tqdm import tqdm 
    
    video_urls = input("Enter urls separated by space: ").split()
    if not os.path.exists("tiktok_videos"):
        os.makedirs("tiktok_videos")
    
    for url in tqdm(video_urls):
        try:
            res = requests.get(url)
            soup = BeautifulSoup(res.text, 'html.parser')
            video_url = soup.find('video').attrs['src']
            with open('temp_video.mp4', 'wb') as f:
                f.write(requests.get(video_url).content)
            video_name = url.split("/")[-1] + ".mp4"
            with open(f"tiktok_videos/{video_name}", 'wb') as f:
                f.write(requests.get(video_url).content)
        except:
            print(f"Failed to download video at {url}")
    
    print("Finished downloading videos!")
    
  9. User

    وما الخطأ Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), main.dict) File "", line 6 video_urls = input(“Enter urls separated by space: “).split() ^ SyntaxError: invalid character '“' (U+201C)

    [Program finished]

  10. Assistant

    الخطأ هو SyntaxError وهو نفس الخطأ السابق والذي يشير إلى وجود حرف غير صالح في السطر 6. يجب استخدام علامات الاقتباس الصحيحة في الأسطر التي تحتوي على النصوص. يمكن استخدام علامات الاقتباس المزدوجة "" بدلاً من علامات الاقتباس الغير صحيحة التي تم استخدامها.

    الكود بعد التعديل:

    import requests 
    from bs4 import BeautifulSoup 
    import os
    from tqdm import tqdm 
    
    video_urls = input("Enter urls separated by space: ").split()
    if not os.path.exists("tiktok_videos"):
        os.makedirs("tiktok_videos")
    
    for url in tqdm(video_urls):
        try:
            res = requests.get(url)
            soup = BeautifulSoup(res.text, 'html.parser')
            video_url = soup.find('video').attrs['src']
            with open('temp_video.mp4', 'wb') as f:
                f.write(requests.get(video_url).content)
            video_name = url.split("/")[-1] + ".mp4"
            with open(f"tiktok_videos/{video_name}", 'wb') as f:
                f.write(requests.get(video_url).content)
        except:
            print(f"Failed to download video at {url}")
    
    print("Finished downloading videos!")
    
  11. User

    لماذا تظهر لي نفس النتيجه رغم التصحيح الكود

  12. Assistant

    قد يكون السبب في ذلك هو عدم حفظ التغييرات التي قمت بها في ملف الكود قبل تشغيله مرة أخرى. يجب حفظ الملف بعد إجراء التعديلات قبل تشغيل البرنامج مرة أخرى. بمجرد حفظ الملف بالشكل الصحيح، يجب أن تتمكن من تشغيل البرنامج الجديد بدون أية أخطاء.

  13. User

    هل هذا الكود صحيح لكي يشتغل علي pydroid3

  14. Assistant

    نعم، الكود الذي قدمته يجب أن يعمل بشكل صحيح على Pydroid 3، ولكن يجب التأكد من تحديث حزم البرامج اللازمة وتثبيتها بشكل صحيح. قم بتثبيت حزمة tqdm باستخدام pip، عن طريق تشغيل الأمر pip install tqdm في وحدة التحكم (console) في Pydroid 3. قم أيضًا بتحديث حزمة requests باستخدام pip install --upgrade requests.

  15. User

    ما الحزم المطلوب تثبيتها لتشغيل الاسكربت

  16. Assistant

    يعتمد الحزم التي تحتاج إليها على المكتبات التي يتم استخدامها في البرنامج الذي تريد تشغيله. في هذا السياق، يحتاج البرنامج إلى حزمة requests و Beautiful Soup و os و tqdm.

    يمكن استخدام الأمر pip install package_name لتثبيت حزم البرامج المطلوبة. يجب استخدام console في Pydroid 3 لتنفيذ هذه الأوامر. يمكن استخدام الأمر pip install beautifulsoup4 لتثبيت حزمة BeautifulSoup، ويمكن استخدام pip install requests لتثبيت حزمة requests، ويمكن استخدام pip install tqdm لتثبيت حزمة tqdm. لا تحتاج حزمة OS إلى تثبيت إذا كنت تستخدم Pydroid 3.