Python "SyntaxError: invalid syntax" hatası

Durum
Mesaj gönderimine kapalı.

wisdomlib

Hectopat
Katılım
18 Kasım 2021
Mesajlar
21
Yer
Bursa
Daha fazla  
Cinsiyet
Erkek
Meslek
Öğrenci
Python:
 url = "https://discordapp.com/api/v6/entitlements/gift-codes/" + nitro + "?with_application=false&with_subscription_plan=true"

 r = requests.get(url)

 if r.status_code == 200:
 file = open("calisan.txt","w")
 file.write (" Çalışıyor " url )
 file.close()

Hata:

File "main.py", line 46 file.write (" Çalışıyor " url ) ^ SyntaxError: invalid syntax

Kodda hatanın nerede olduğunu buldum ama nasıl çözeceğimi bulamadım yardım eder misiniz?
 
Python:
file.write(f"Çalışıyor: {url}")
 
Python:
file.write("Çalışıyor", url)
Virgülü unuttunuz sanırım.

Traceback (most recent call last): File "main.py", line 46, in <module> file.write (" Çalışıyor ", url ) TypeError: write() takes exactly one argument (2 given)

Diyor.
 
Traceback (most recent call last): File "main.py", line 46, in <module> file.write (" Çalışıyor ", url ) TypeError: write() takes exactly one argument (2 given)

Diyor.
Güncelledim mesajı.
 
Traceback (most recent call last): File "main.py", line 46, in <module> file.write(f"Çalışıyor: {url}") io.UnsupportedOperation: not writable
Diyor şimdide.
 
Python:
with open("calisan.txt", "w") as f:
    url = "https://discordapp.com/api/v6/entitlements/gift-codes/" + nitro + "?with_application=false&with_subscription_plan=true"
    r = requests.get(url)
    if r.status_code == 200:
        f.write(f"Çalışıyor {url}")
Böyle deneyin hocam.
 
File "main.py", line 39. url = "https://discordapp.com/api/v6/entitlements/gift-codes/" + nitro + "?with_application=false&with_subscription_plan=true" ^ IndentationError: expected an indented block.

Böyle diyor.
 
File "main.py", line 39. url = "https://discordapp.com/api/v6/entitlements/gift-codes/" + nitro + "?with_application=false&with_subscription_plan=true" ^ IndentationError: expected an indented block.

Böyle diyor.
Düzgün kopyala yapıştır yaptığınızdan emin misiniz? Kodunuzun geri kalanını bilmediğimden bu kadar yardım edebiliyorum.
 
Durum
Mesaj gönderimine kapalı.

Technopat Haberler

Yeni konular

Geri
Yukarı