[問題] Python 子程序內變數提取至主程序問題

看板Python作者 (zero06795)時間5年前 (2019/03/24 00:40), 5年前編輯推噓0(006)
留言6則, 2人參與, 5年前最新討論串1/2 (看更多)
各位大佬們請幫幫新手小白~我想了好久了 先謝謝大家了 請問python主程序運行到觸發副程式(open_file)後,要怎?把副程式變數值提輸出到主程 序 def open_file(): filename = tf.askopenfilename() if filename != '': app=xw.App(visible=False) wb=xw.Book(filename) sht=wb.sheets[0] ros=sht.used_range.rows.count cos=sht.used_range.columns.count print(ros) wb.close() app.quit() else: tkinter.messagebox.showerror(title='error', message='no select') -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.173.71.64 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1553359232.A.F6F.html

03/24 09:04, 5年前 , 1F

03/24 09:04, 5年前 , 2F

03/24 09:04, 5年前 , 3F
eturn-multiple-values-from-a-function
03/24 09:04, 3F

03/24 09:06, 5年前 , 4F
03/24 09:06, 4F

03/25 08:18, 5年前 , 5F
感覺用return是沒錯的,但我if 句尾加上return 主程序
03/25 08:18, 5F

03/25 08:18, 5年前 , 6F
一樣ros值是錯的= =“
03/25 08:18, 6F
※ 編輯: zero06795 (118.171.230.146), 03/26/2019 08:25:02
文章代碼(AID): #1Sbc60zl (Python)
文章代碼(AID): #1Sbc60zl (Python)