지금 몇 주 동안 프로젝트를 진행했으며 최종 기한이 끝났습니다. 하나에서 설정 한 모든 작업을 완료했습니다. 내 자신에 적어도 몇 주 동안 그것을해라. 그러나 나는 somone가 나를 도울 수 있었던 지 그렇게 단지 그것을 wroking 할 수있다. 나는 정말로 그것을 apreciate 할 것이다. 작업은 생성 된 데이터를 txt 파일에 저장하는 프로그램을 만드는 것이 었습니다. 이것은 지금까지 제 코드입니다. 결과를 .txt 파일로 저장하는 방법
import random
char1=str(input('Please enter a name for character 1: '))
strh1=((random.randrange(1,4))//(random.randrange(1,12))+10)
skl1=((random.randrange(1,4))//(random.randrange(1,12))+10)
print ('%s has a strength value of %s and a skill value of %s)'%(char1,strh1,skl1))
char2=str(input('Please enter a name for character 2: '))
strh2=((random.randrange(1,4))//(random.randrange(1,12))+10)
skl2=((random.randrange(1,4))//(random.randrange(1,12))+10)
print('%s has a strength value of %s and a skill value of %s'%(char1,strh1,skl1))
char1[1]="Strength now {} ".format(strh1)
char1[2]="Skill now {} ".format(skl1)
char2[1]="Strength now {} ".format(strh2)
print()
char2[2]="Skill now {}".format(skl2)
print()
myFile=open('CharAttValues.txt','wt')
for i in Char1:
myFile.write (i)
myFile.write ('\n')
for i in Char2:
myFile.write (i)
myFile.write('\n')
myFile.close()
지금 나는 이것이 TXT에 기록하지만려고하고 자사하지 작업 내가 그것을 저장하기위한 것입니다 프로그램의 끝 부분에 도착 이제까지 내가이 오류 얻을 때 :
Traceback (most recent call last):
File "E:\CA2 solution.py", line 14, in <module>
char1[1]="Strength now {} ".format(strh1)
TypeError: 'str' object does not support item assignment
을
Im은 잘 작동하지 않으며, 파이썬 3.3.2에서 작동하도록 도와 줄 수 있다면 정말 고맙겠습니다. 마감일은 내일이고 올바르게 처리하지 않으면 나쁜 결과가 발생할 것이기 때문에, 그것의 다만 나가 지금 당분간 그것을 독자적으로 파악하는 것을 시도하고있다 그리고 누군가가 그것에게 일을 얻을 수 있던 경우에 나가 남겨둔 어떤 시간도 없으면 나는 진짜로 그것을 평가할 것입니다, 감사합니다 순전히 fo r 도움.
이 당신이 당신의 GCSEs에 부정 행위를 도와주는 사이트가 아닙니다. – jonrsharpe
가능한 [파이썬 3.3.2의 Txt로 저장하는 문제] (http://stackoverflow.com/questions/23137383/issue-with-saving-into-a-txt-in-python-3-3- 2) – jonrsharpe