這裏是我的代碼(抱歉亂碼):爲什麼我的程序添加(「」,'我的文件的名稱
def main():
pass
if __name__ == '__main__':
main()
from easygui import *
import time
import os
import random
import sys
##multenterbox(msg='Fill in values for the fields.', title=' ', fields=(), values=())
msg = "Enter your personal information"
title = "Credit Card Application"
fieldNames = ["First name",'Last name','email',"Street Address","City","State","ZipCode",'phone','phone 2)']
fieldValues = [] # we start with blanks for the values
fieldValues = multenterbox(msg,title, fieldNames)
# make sure that none of the fields was left blank
def make(x):
xys = x,".acc"
xyzasd = str(xys)
tf = open(xyzasd,'a+')
tf.writelines(lifes)
tf.writelines("\n")
tf.writelines("credits = 0")
tf.close
def add(x):
nl = "\n"
acc = ".acc"
xy = x + acc
exyz = xy
xyz = exyz
xxx = str(xyz)
tf = open('accounts.dat',"a+")
tf.writelines(nl)
tf.writelines(xxx)
tf.close
while 1:
if fieldValues == None: break
errmsg = ""
for i in range(len(fieldNames)-1):
if fieldValues[i].strip() == "":
errmsg += ('"%s" is a required field.\n\n' % fieldNames[i])
if errmsg == "":
break # no problems found
fieldValues = multenterbox(errmsg, title, fieldNames, fieldValues)
names = enterbox(msg= ('confirm FIRST name and the FIRST LETTER of the persons LAST name'))
##txt = "acc"
##na = str(name)
##name = (names)
life = (str(fieldValues))
lifes = life,'\n'
herro = ("Reply was: %s" % str(fieldValues))
correct = buttonbox(msg=(herro,'\n is that correct'),choices = ('yes','no','cancel'))
if correct == "yes":
make(names)
add(names)
elif correct == "no":
os.system('openacc.py')
time.sleep(0.5)
sys.exit()
else:
os.system('cellocakes-main.py')
sys.exit()
os.system('cellocakes-main.py')
我不知道是什麼問題,我也很抱歉,它的編程有多鬆散我有一塊白板來幫助我繼續編程(我只有13)對不起。我個人認爲這個問題是在def add區域的語法,但因爲我還是新的,我不知道「看不到這個問題,我個人很希望能有一個比較有經驗的程序員幫助我
該程序在哪裏添加什麼? – Hyperboreus
當你使用'if __name__ =='__main __''時,你應該把所有東西,除了導入,類定義和函數定義放在'main'中。它應該阻止您的代碼在作爲模塊導入時被當作腳本處理。 – user2357112
請正確指定您的變量和功能,否則當您30歲時,請查看您寫入13歲的代碼,您會對自己感到非常慚愧,相信我 - 曾經在那裏:D –