Здесь есть две проблемы. Первый - после моего цикла main (), в то время как на "вы хотите загрузить еще один?"Когда вводится «y», я хочу, чтобы он запускал timer1 () и main () одновременно. Но вместо этого он запускает только timer1 (), а не main (). Я пробовал многопроцессорность, но я не очень хорош в этом. Если вы знаете, как использовать многопроцессорную обработку для этого сценария, это было бы удивительно.
Вторая проблема - после того, как timer () завершил обработку, когда вы выполняете выбор номер 5. Вместо обновления переменных, таких как totalviews, totallikes и подписчики,Он сбрасывает их обратно в исходное состояние. Если вы знаете, как предотвратить это, это было бы удивительно.
import time
import multiprocessing
import random
print('')
print("you decided to start a youtube channel")
done = False
start = 1
done2 = False
done1 = False
true = 1
totalviews = 0
videoViews = 0
totallikes = 0
videolikes = 0
totaldislikes = 0
videodislikes = 0
subscribers = 7
videolength = 0
midroles = 0
uploadTimer1 = 0
waitTimer1 = 0
x = 0
comadymins = 0
comadysecs = 0
subscribersGained = 0
level = 1
placeholder = 1
def comadylevel():
global level
global placeholder
global subscribers
global videoViews
global videolikes
global subscribersGained
global totallikes
global totalviews
global subscribers
global x
rview = random.randint(1, 10)
time.sleep(0.1)
if placeholder == 1:
videoViews = round(rview * level * subscribers)
videolikes = round(rview * level * subscribers / 5)
subscribersGained = round(rview * level / 5)
time.sleep(0.1)
if placeholder == 2:
totalviews += videoViews
totallikes += videolikes
subscribers += subscribersGained
def timer1():
global uploadTimer1
global waitTimer1
global x
global true
global videolikes
global videoViews
global subscribersGained
time.sleep(.75)
while True:
x = 1
if x == 1:
print(uploadTimer1, 'mins remaining')
time.sleep(5)
uploadTimer1 -= 1
if uploadTimer1 == 0:
x = 0
waitTimer1 = 0
print('you comady video is done being uploaded.')
print('Would you like to see the video statistics')
comadylevel()
timer1input = input('')
if timer1input == 'y':
time.sleep(1)
print('Your views were', videoViews)
print('Your likes were', videolikes)
print('Your gained', subscribersGained, 'subscribers')
true = 1
main()
break
if timer1input == 'n':
print('okay')
true = 1
videoViews = 0
videolikes = 0
subscribersGained = 0
main()
break
def main():
global waitTimer1
global x
global uploadTimer1
global true
global done1
global done2
while not done1:
time.sleep(1.25)
print('')
print('what type of video will you make')
print('1. comedy')
print('2. gaming')
print('3. science')
print('4. check timer')
print('5. check total statistics')
UserInput = input('')
if UserInput == '1':
if waitTimer1 == 0:
comadymins = random.randint(10, 30)
comadysecs = random.randint(0, 60)
time.sleep(0.1)
print('video length will be', comadymins, ":", comadysecs)
time.sleep(1)
done2 = False
while not done2:
if 20 <= comadymins <= 29 and comadysecs <= 59:
print('would you like to upload now?')
time.sleep(.5)
UserInputtest = input('')
if UserInputtest == 'y':
print('video is uploading')
print('it will take 4 mins')
uploadTimer1 += 1
waitTimer1 += 1
print('would you like to upload another video?')
UserInput = input('')
if UserInput == 'y':
timer1()
x = 1
done2 = True
done1 = False
main()
break
if UserInput == 'n':
timer1()
print('okay, timer started')
time.sleep(0.1)
x = 1
done2 = True
done1 = True
break
if UserInputtest == 'n':
print('okay')
break
else:
print('invalid input')
if 10 <= comadymins <= 19 and comadysecs <= 59:
print('would you like to upload now?')
time.sleep(.5)
UserInputtest = input('')
if UserInputtest == 'y':
print('video is uploading')
print('it will take 3 mins')
uploadTimer1 += 1
waitTimer1 += 1
print('would you like to upload another one?')
UserInput = input('')
if UserInput == 'y':
timer1()
x = 1
done2 = True
done1 = False
main()
break
if UserInput == 'n':
timer1()
x = 1
print('okay, timer started')
time.sleep(0.1)
done2 = True
done1 = True
if UserInputtest == 'n':
print('okay')
break
else:
print('invalid input')
else:
print('you already have a video running')
time.sleep(1)
if UserInput == '4':
print('okay')
print(uploadTimer1, "mins remaining")
if UserInput == '5':
print("total subscribers", subscribers)
print("total views", totalviews)
print("total likes", totallikes)
Main=multiprocessing.Process(target=main())
startinput = input('')
if startinput == 'ok':
main()