Sfoglia il codice sorgente

上傳檔案到 'AI_anchor2'

oak 2 anni fa
parent
commit
0c275d39df
1 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 8 2
      AI_anchor2/main1.py

+ 8 - 2
AI_anchor2/main1.py

@@ -235,8 +235,14 @@ def text_to_short_vedio_create(read_csv_use="導盲犬協會.csv",pwd_use="導
     ck_anchor=None
     #時間
     time_= 0
-    
-    csv_use=pd.read_csv("input/"+read_csv_use)
+    try:
+        if read_csv_use[-4:]==".csv":
+            csv_use=pd.read_csv("input/"+read_csv_use)
+        elif read_csv_use[-5:]==".xlsx":
+            csv_use = pd.read_excel("input/"+read_csv_use)
+    except:
+        print("excel不存在或excel格式不支援或損毀")
+        return
     csv_use=csv_use.dropna(how='all')
     csv_use.reset_index(inplace=True)