Python "in" in einer IF-verzweigen funktioniert nicht?
Hallo zusammen,
ich möchte per Tastendruck den Link zu einem Screenshot z.B. https://i.imgur.com/qk5TpU0.png
aus meiner Zwischenablage in ein Google Spreadshead hochladen. Diese sollen natürlich untereinander erscheinen und nicht doppelt. Hier funktioniert aber nicht der "in" Operator.
Bild vom Spreadshead: https://i.imgur.com/gOxxDeN.png
Der Code: "
import keyboard
from tkinter import Tk
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# use creds to create a client to interact with the Google Drive API
scope = ["https://spreadsheets.google.com/feeds", 'https://www.googleapis.com/auth/spreadsheets',
"https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
# Find a workbook by name and open the first sheet
# Make sure you use the right name here.
sheet = client.open("test für api").sheet1
def check_value_existence():
row = 2 # Reihe
col = 2 # Spalte
value = sheet.cell(col, row).value
clipboard = Tk().clipboard_get()
if "imgur" in value:
while True:
col = col + 1
value = sheet.cell(col, row).value
if "imgur" in value:
break
print("found", col)
col = col - 1
if value != clipboard:
sheet.update_cell(2, 2, clipboard)
while True:
if keyboard.read_key() == "p":
print("You pressed p")
check_value_existence()
"