綁定帳號登入

Android 台灣中文網

打印 上一主題 下一主題

[求助] (PYTHON)

[複製連結] 查看: 28616|回覆: 4|好評: 0
跳轉到指定樓層
樓主
Stephaneliu2009 | 收聽TA | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
發表於 2021-2-19 13:32

馬上加入Android 台灣中文網,立即免費下載應用遊戲。

您需要 登錄 才可以下載或查看,沒有帳號?註冊

x
本帖最後由 Stephaneliu2009 於 2021-2-19 14:19 編輯

可以請大家幫忙我看我的Python程式哪裡有錯嗎?
==================================
1.
#Release 1.01

#@2021/02/19 Creeated By Stephane
#FR_racingV1beta21

#IMPORT MODULE
import random
import math
import time
from tkinter import Tk
import os
import shutil

#SET TKINTER
window = Tk()
window.title("FR")
window.maxsize(200,200)
window.resizable(0,0)
label1 = Label1(window, text="0")
label1.pack(side = TOP)

#DEFINDFIITITION VARABLES
count1="0"
count2="0"
tmp1="0"
tmp2="0"
set1="0"
set2="0"

#DEFINDFIITITION IMAGES and ICON
def FRASCII1():
    tmp1="0"
    tmp2="0"
    print("""                                                         -                                                                             
                      |---|----------------|             / ---                                                                        
                      |   |----------------|            /      --                                                                     
                      |   |                           /-          --                                                                  
                      |   |                          /          -----------                                                            
                      |   |----------------|        /----------/         --                                                            
                      |   |------------------      /  -                                                                                
                      |   |                       /     --                                                                             
                      |   |                     /-         --                                                                          
                      |   |                    /              -                                                                                 |   |                   /                 --                                        ------------------/         
                      |---|                  -                     --                  -------------------/                             
                                                                    ------------------/                                                
                                                 ------------------/                                                                    
                             -------------------/                                                                                       
          ------------------/                                                                                                           
---------/                                                                                                                              

""")
   
def FRWIN():
    tmp1="0"
    tmp2="0"
    window.title("FR")
    label1 = Label1(window, text="YOU WIN!!")
    window.mainloop
   
def FRWIN():
    tmp1="0"
    tmp2="0"
    window.title("FR")
    label1 = Label(window, text="YOU LOSE")
    window.mainloop
   
def SCOREPLUSONE():
    tmp1="0"
    tmp2="0"
    int(count1)+int(count2)
   
def SCOREMINUSONE():
    tmp1="0"
    tmp2="0"
    int(count1)-int(count2)
   
def doMain():
   
def START():
    tmp1="0"
    tmp2="0"
    print("Welcome To FR Racing V1 2021")
    time.sleep(1.0)
    tmp1=input("Do You Want To Install The Game? Y/n")
    if tmp1=="Y" or tmp1=="y"
       return tmp2==input("Where Do Want To Install? ex:C:/Programfile")
    elif tmp1=="n"
       return doMain()
    else
       return tmp1==input("Do You Want To Install The Game? Y/n")






2.import random
import time

print()
print("UFO Password")
print()
time.sleep(1.0)
print("First, Enter A Capital Letter and then A Small Letter")
time.sleep(1.0)
print("To Disable The Explosion Function")
print()
input("Press Enter to continue...")

def guess_letter():
    return random.choise("abcdefghijklmnopqrstuvwxyz")

first_letter = guess_letter()
#print(first_letter)

def guess_letter2():
    return eamdon.choise("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
second_letter = guess_letter2()
#print(second_letter)
no_explosion=False

def fun1():
    print("You Save The Humans!!!!")
    no_explosion=True
    tmp1 = input("press any key to continue...")
    exit()
    break
if fg < first_letter:
        print("letter Behind")
if fg> first_letter:
        print("letter next-to")
        
for x in range(3):
    fg = input("first_letter:")
    fg2 = input("second_letter:")
if fg == first_letter and fg2 == second_letter:
        fun1()
else
  print("The Earth Exploded")
  time.sleep(1.0)
  tmp1 = input("press any key to continue...")
  exit()

===============================================================================
寫到一半
ASCII會有點怪
開發完成後,會送給有留言詞留言的人!
FR_RACING     
         



「用Android 就來APK.TW」,快來加入粉絲吧!
Android 台灣中文網(APK.TW)
收藏收藏 分享分享 分享專題
用Android 就來Android 台灣中文網(https://apk.tw)
回覆

使用道具 舉報

沙發
rabrus | 收聽TA | 只看該作者
發表於 2021-3-13 14:00
建議選用一個好的 IDE 來學習,可以省掉不少不必要的除錯時間。
我個人使用 pycharm ,可以嘗試看看。
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

板凳
chobitscu | 收聽TA | 只看該作者
發表於 2022-6-26 01:24
1. 檢查if, elif, else 後面是不是都有":",大多都是語法錯誤,應該很容易透過error msg 知道為什麼,而且你也只附上程式碼片段,沒有 tkinter,無法除錯其餘的部分
2. 一樣,檢查語法問題,else 後面有缺":"。choice 寫成 choise。fg 沒有定義就使用。
請使用相關的IDE或是手動執行看看,應該都能發現問題。
如果是基礎除錯都有問題的話,建議還是看本入門的書籍,或是上課會比較好。
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

地板
jason1699 | 收聽TA | 只看該作者
發表於 2023-5-30 13:53
第一段修改如下:
# Release 1.01

# @2021/02/19 Created By Stephane
# FR_racingV1beta21

from tkinter import Tk, Label

# Set up Tkinter
window = Tk()
window.title("FR")
window.maxsize(200, 200)
window.resizable(0, 0)
label1 = Label(window, text="0")
label1.pack(side="top")

# Definition Variables
count1 = "0"
count2 = "0"
tmp1 = "0"
tmp2 = "0"
set1 = "0"

# Definition Images and Icon
def FRASCII1():
    tmp1 = "0"
    tmp2 = "0"
    print("""
        ASCII art here
    """)

def FRWIN():
    tmp1 = "0"
    tmp2 = "0"
    window.title("FR")
    label1 = Label(window, text="YOU WIN!!")
    window.mainloop()

def FRLOSE():  # Changed the function name to FRLOSE (previously FRWIN, which was incorrect)
    tmp1 = "0"
    tmp2 = "0"
    window.title("FR")
    label1 = Label(window, text="YOU LOSE")
    window.mainloop()

def SCOREPLUSONE():
    tmp1 = "0"
    tmp2 = "0"
    int(count1) + int(count2)

def SCOREMINUSONE():
    tmp1 = "0"
    tmp2 = "0"
    int(count1) - int(count2)

def doMain():
    pass  # Placeholder for the doMain function, implement your logic here

def START():
    tmp1 = "0"
    tmp2 = "0"
    print("Welcome To FR Racing V1 2021")
    time.sleep(1.0)
    tmp1 = input("Do You Want To Install The Game? Y/n")
    if tmp1 == "Y" or tmp1 == "y":
        return tmp2 == input("Where Do Want To Install? ex:C:/Programfile")
    elif tmp1 == "n":
        return doMain()
    else:
        return tmp1 == input("Do You Want To Install The Game? Y/n")








------------------------------------------------------------------------------------------------



第二段修改如下:

import random
import time

print()
print("UFO Password")
print()
time.sleep(1.0)
print("First, Enter A Capital Letter and then A Small Letter")
time.sleep(1.0)
print("To Disable The Explosion Function")
print()
input("Press Enter to continue...")

def guess_letter():
    return random.choice("abcdefghijklmnopqrstuvwxyz")

first_letter = guess_letter()
#print(first_letter)

def guess_letter2():
    return random.choice("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

second_letter = guess_letter2()
#print(second_letter)

no_explosion = False

def fun1():
    print("You Save The Humans!!!!")
    global no_explosion  # Added global keyword to modify the global variable
    no_explosion = True
    tmp1 = input("Press any key to continue...")
    exit()

for x in range(3):
    fg = input("first_letter:")
    fg2 = input("second_letter:")
    if fg == first_letter and fg2 == second_letter:
        fun1()
   
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

5
vic003627 | 收聽TA | 只看該作者
發表於 2023-9-26 08:40
chatGPT 或許可以將你的程式碼貼上後

請她幫你檢查也是個不錯的選擇
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則