2017-02-06 5 views
0

を私は無効な構文エラーがあり、スペースがアスタリスクMakeHumanファイルを書き込むためにPythonの使用:無効な構文エラー

"* modifier macrodetails/Caucasian ' + str(CaucasianQuotient) + '\n\" 

で強調表示され、私は全部を介して複数回行ってきましたが、私はまだ知りません何が起こっていないか

ListOfBodyShape = ['Round', 'RoundBottom', 'RoundTop', 'RoundMuscular', 'MuscularBottom', 'MuscularTop', 'Muscular', 'TopBottom'] 
ListOfHeight = ['Medium', 'MediumShort', 'TallMedium', 'TallShort', 'Tall', 'Short'] 
ListOfHairStyle = ['Short', 'Long', 'CurlyShort', 'CurlyLong'] 
Gender = ['Male', 'Female'] 
ListOfAges = ['Child', 'Teen', 'Adult', 'Elder'] 

MuscleQuotient = 0 
AfricanQuotient = 0 
ProportionQuotient = 0 
GenderQuotientQuotient = 0 
HeightQuotient = 0 
BreastSizeQuotient = 0 
AgeQuotient = 0 
BreastFirmnessQuotient = 0 
AsianQuotient = 0 
CaucasianQuotient = 0 
WeightQuotient = 0 

for a in range(len(ListOfBodyShape)): 
    for b in range(len(ListOfHeight)): 
     for c in range(len(ListOfHairStyle)): 
      for d in range(len(Gender)): 
       for e in range(len(ListOfAges)): 
        f = open(ListOfBodyShape[a] + ' ' + ListOfHeight[b] + ' ' + ListOfHairStyle[c] + ' ' + Gender[d] + ' ' + ListOfAges[e] + '.mhm', 'w') 

        f.write('version v1.1.0\n\ 
        tags untitled\n\ 
        camera 6.0 347.5 -0.113847193662 0.694580827356 -0.399507358182 0.6375\n\ 
        modifier macrodetails-universal/Muscle ' + str(MuscleQuotient) + '\n\ 
        modifier macrodetails/African ' + str(AfricanQuotient) + '\n\ 
        modifier macrodetails-proportions/BodyProportions '+ str(ProportionQuotient) +'\n\ 
        modifier macrodetails/Gender ' str(GenderQuotient) + '\n\ 
        modifier macrodetails-height/Height ' + str(HeightQuotient) + '\n\ 
        modifier breast/BreastSize' + str(BreastSizeQuotient) + '\n\ 
        modifier macrodetails/Age ' + str(AgeQuotient) + '\n\ 
        modifier breast/BreastFirmness ' + str(BreastFirmnessQuotient) + '\n\ 
        modifier macrodetails/Asian ' + str(AsianQuotient) + '\n\ 
        modifier macrodetails/Caucasian ' + str(CaucasianQuotient) + '\n\ 
        modifier macrodetails-universal/Weight ' + str(WeightQuotient) + '\n\ 
        eyes HighPolyEyes 2c12f43b-1303-432c-b7ce-d78346baf2e6\n\ 
        clothesHideFaces True\n\ 
        skinMaterial skins/default.mhmat\n\ 
        material HighPolyEyes 2c12f43b-1303-432c-b7ce-d78346baf2e6 eyes/materials/brown.mhmat\n\ 
        subdivide False\n') 
+0

'' Eye HighPolyEyes'系の周りに... '+ '\ n''がありません –

答えて

1

まず、ループに範囲が必要ないことを理解する必要があります。 Pythonの命名-規則は大文字


で変数を開始しないと言う、私は1を書き込もうとしないことをお勧め:

for a in range(len(ListOfBodyShape)): # a range 
    x = ListOfBodyShape[a] # get value with index 

for x in ListOfBodyShape: # get value 

追記とまったく同じですテキストの大きな塊。

出力がどのように表示されるべきか分かりませんが、Pythonには複数行の文字列が含まれているため、必要がない限り自分で\nを書くべきではありません。

さらに、\n\は単なる改行ではありません。

だから、この

f.write("""version v1.1.0 
tags untitled 
camera 6.0 347.5 -0.113847193662 0.694580827356 -0.399507358182 0.6375\n""") 

で始まり、その後、私はあなたが文字列フォーマットを使用することをお勧めします。

f.write("modifier macrodetails-universal/Muscle {}\n".format(MuscleQuotient)) 

そしてサインはこの行のstrの前に欠けているf.close()

を使用することを忘れないでくださいそれとも、この

filename = "{} {} {} {} {}.mhm".format(ListOfBodyShape[a], ListOfHeight[b], ListOfHairStyle[c], Gender[d], ListOfAges[e]) 
with open(filename), 'w') as f: 
    f.write(...) 
# f.close() automatically 
2

A "+" を行うことができます。

'modifier macrodetails/Gender ' str(GenderQuotient) + '\n\ " 

また、f.close()を終わり。

関連する問題