這是我的代碼:
def videoConv(sourceDir, targetDir):
videoSourceDeclaration(sourceDir, targetDir)
input(print("\nis this correct?\n[y]/[n] (yes or no): "))
列印這個:
is this correct?
[y]/[n] (yes or no):
None
如何阻止它列印“無”?我讀過我應該使用return,但我不確定我應該做什么。
此外,這是整個 videoSourceDeclaration 函式:
def videoSourceDeclaration(sourceDir, targetDir):
sourceDir = input("Input source directory (leave blank for default): ")
os.system('cls||clear')
os.chdir("..")
print("source directory: " os.getcwd())
targetDir = input("\nInput target directory (leave blank for default): ")
if targetDir == "":
if platform == "linux":
targetDir = ("~\\videos")
# not sure of the linux dir, change later and add macos")
elif platform == "win32":
targetDir = ("c:\\" "users\\" getpass.getuser() "\\" "videos")
if targetDir == ("~\\videos") or ("c:\\" "users\\" getpass.getuser() "\\" "videos"):
isTargetDirDefault = True
os.system('cls||clear')
print("source directory: " os.getcwd() "\ntarget directory: " targetDir)
uj5u.com熱心網友回復:
你在這里混合了一些東西。
為了列印用戶的輸入,您必須首先獲取它。您使用該input()函式正確執行了此操作,但這將回傳結果。這就是您需要列印的內容。
所以你應該改變你的代碼:
input(print("\nis this correct?\n[y]/[n] (yes or no): "))
對此
print(input("\nis this correct?\n[y]/[n] (yes or no): "))
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/391624.html
上一篇:在R中的函式中使用匿名函式
