Python的range()函数未循环

时间:2019-12-27 14:03:40

标签: python python-3.x range

我试图制作一个带有2个可能输出的“随机”文本程序,随机化有效,但import time import pyautogui import random time.sleep(2) for i in range(50): if int(random.randint(1,2)) == 1: pyautogui.typewrite('bruh1') pyautogui.press('enter') random.randint(1,2) elif int(random.randint(1,2)) == 2: pyautogui.typewrite('bruh2') pyautogui.press('enter') random.randint(1,2) 不起作用。我总是犯一些愚蠢的错误,所以不要为一个愚蠢的小事情而努力我一个人

{{1}}

2 个答案:

答案 0 :(得分:4)

x是random.randint()返回的随机数。不确定调用x()是否正确。您能仔细看看那部分吗?

答案 1 :(得分:3)

java.lang.RuntimeException: 
at android.app.ActivityThread.installProvider (ActivityThread.java:6210)
  at android.app.ActivityThread.installContentProviders (ActivityThread.java:5757)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5696)
  at android.app.ActivityThread.-wrap2 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1691)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:186)
  at android.app.ActivityThread.main (ActivityThread.java:6509)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:914)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:804)

Caused by: java.lang.ClassNotFoundException: 
  at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:380)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
  at android.app.ActivityThread.installProvider (ActivityThread.java:6195)