일부 입력을 함께 추가하여 파일 이름을 만들려고했으나 그 사이에 공백이있는 것 같습니다. replace를 사용하여 공간을 없애고 결합하려고했습니다. 그러나 조인은 정의되지 않았으며 'tuple'객체에는 'replace'속성이 없습니다.문자열에서 공백을 제거하려고 시도했지만 'tuple'객체에 'replace'속성이 없습니다.
변경 :
fnws = name,".",pictype
으로
,
를 사용하여 튜플을 생성하고, 당신이 필요로하는 문자열이므로
from turtle import Turtle, Screen
def k100():
tsave = Turtle()
tsavescreen = tsave.getscreen()
pictype = input("What type of photo would you like this to be saved as? (png, jpg, pdf, ...) ")
name = input("What would you like to call your masterpiece? ")
fnws = name,".",pictype #fnws means file_name_with_spaces
join(fnws)
fnns = fnws.replace(" ", "") #fnns means file_name_no_spaces
tsavescreen.getcanvas().postscript(file=fnns, colormode='color')
#open("C:\Users\GURNHH\OneDrive - Rugby School\ICT\Python").close()
#open("pythontest11.pdf").close()
print("It has been saved as: ", fnns)
print("It has been saved as: ", fnns)
고맙다을 너무 많이 갈 수 스트립 기능에 대한 자세한 내용은이
fnws = "{}.{}".format(name.strip(),pictype.strip())
처럼 사용! – Gurneyguy
파일을 열 수없는 이유를 알고 계십니까? 나는 어도비, 마이크로 소프트 가장자리 및 낱말을 사용하여 시도했다, 그러나 어느 쪽이든. (btw 나는 거북이로 그려진 그림을 구하려고 노력하고있다) – Gurneyguy