作者zero06795 (zero06795)
看板Python
標題[問題] Python 子程序內變數提取至主程序問題
時間Sun Mar 24 00:40:30 2019
各位大佬們請幫幫新手小白~我想了好久了 先謝謝大家了
請問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
→ sating00: eturn-multiple-values-from-a-function03/24 09:04
→ zero06795: 感覺用return是沒錯的,但我if 句尾加上return 主程序03/25 08:18
→ zero06795: 一樣ros值是錯的= =“03/25 08:18
※ 編輯: zero06795 (118.171.230.146), 03/26/2019 08:25:02