python中变量pa和pa一样吗_在Python中使用另一个函数中的一个变量

我有一个程序,下载视频文件在这里它是完整的,别担心它是一个短程序。在import pafy

def download():

url = raw_input('Please enter the path to the video\n')

video = pafy.new(url)

vid_title = video.title

best = video.getbest()

streams = video.streams

print(vid_title)

for stream in streams:

print(stream)

print'Resolution: ',best.resolution,'\nExtension : ', best.extension

user_choice = raw_input("Do you want to download this video\ny or n\n")

if user_choice == 'y':

print'Your video will downloaded soon'

filename = best.download(filepath = '/home/mark/new_projects')

another_download()

elif user_choice =='n':

print'You have chosen not to download a video'

another_download()

def another_download():

another_choice = raw_input('Would you like to download another video\ny or n\n')

if another_choice == 'y':

download()

else:

print'Thank for using my program'

download()

我想把它分解成更小的函数。我试过这样做:

^{pr2}$

但当我尝试这个时,我得到一个错误,告诉我最好的还没有被宣布。我不想将best声明为全局变量。有没有办法在另一个函数中使用一个函数中的变量?在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值