![](/img/trans.png)
[英]How do I schedule a python script (main.py from Github Rep) in anaconda ssf environment?
[英]Python script... I need to take API Key from the command prompt into Main.py
需要幫助從命令提示符獲取 API 密鑰並將其插入 Excel 工作表的特定單元格。 我打算將它添加到 Main.py 中。 但不確定腳本的位置。
API_key = input("What is the API key? \n")
然后我打算使用 Openpyxl 將其添加到 Excel 工作表上的單元格中。 但是我在哪里添加這段代碼? 在 Main.py 腳本中? 直接取自 Openpyxl 文檔:
from openpyxl import Workbook
wb = Workbook()
# grab the active worksheet
ws = wb.active
# Data can be assigned directly to cells
ws['A1'] = API_key
# Save the file
wb.save("sample.xlsx")
您描述中的代碼有效。 你可以這樣做:
from openpyxl import Workbook
book = Workbook()
sheet = book.active
API_key = input("What is the API key? \n")
sheet['A1'] = API_key
book.save("sample.xlsx")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.